basename-with a directory name delivers portions of the pathname

 <  Day Day Up  >  

basename ”with a directory name delivers portions of the pathname

 basename string [ suffix ] dirname string 

basename deletes any prefix ending in / (forward slash) and the suffix (if present in string ) from string , and prints the result on the standard output.

Example A.6.
 1   basename /usr/local/bin 2   scriptname="`basename 
 1 basename /usr/local/bin 2 scriptname="`basename $0`" 
`"

EXPLANATION

  1. Strips off the prefix /usr/local/ and displays bin .

  2. Assigns just the name of the script, $0 , to the variable scriptname.

 <  Day Day Up  >  


UNIX Shells by Example
UNIX Shells by Example (4th Edition)
ISBN: 013147572X
EAN: 2147483647
Year: 2004
Pages: 454
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net