tail of a path

Gary Weimer 253-7796 weimer at garden.ssd.kodak.com
Wed May 15 07:09:30 AEST 1991


In article <=+_hsq. at rpi.edu>, fitz at mml0.meche.rpi.edu (Brian Fitzgerald)
writes:
|> afsipmh at cidsv01.cid.aes.doe.CA writes:
|> >Basically I want to be able to get the name of a script out
|> >of $0 without the path.
|> 
|> Use basename if it's available on your machine.  It's not a shell
|> builtin, though.  Use backquotes if you want to use the result in your
|> script.
|> 
|> prog=`basename $0`

or if you don't have basename (or don't want to worry about it):

prog=`echo $0|awk -f/ '{print $NF}'`

weimer at ssd.kodak.com ( Gary Weimer )



More information about the Comp.unix.shell mailing list