Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: $cd /bin



 On Sat, 1 Dec 2007 18:17:18 -0600 
Brian Medley <[hidden email]> wrote: 

> #!/bin/sh 
> # $FreeBSD: src/usr.bin/alias/generic.sh,v 1.1 2002/07/16 22:16:03 wollman Exp $ 
> # This file is in the public domain. 
> ${0##*/} ${1+"$@"} 
> $ 
> 
> What does this do? 

As Kristian says, the first part '${0##*/}" cleans up the name of the 
command. 
eg. './foo' becomes 'foo' 

The second part concatenates the arguments. 
So, if the command is executed as: 
./foo abc def ghi 

the line '${0##*/} ${1+"$@"}' then becomes: 
foo abc def ghi 

The ${...} is a shell builtin curly-bracket string pattern matching. 
In the case of ${0##*/} the ## matches the beginning of the variable 0 
up to and including the /. So that '/usr/bin/foo' becomes 'foo' 

-- 
Jerry Feldman <[hidden email]> 
Boston Linux and Unix user group 
http://www.blu.org PGP key id:C5061EA9 
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9 
_______________________________________________ 
Discuss mailing list 
[hidden email] 
http://lists.blu.org/mailman/listinfo/discuss
 


BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org