December 1999
Beginner
528 pages
11h 10m
English
Format:
basename path
Basename will strip the path from a supplied pathname and return just the filename. Commonly used in usage statements in scripts, in this case substitution is used when echoing out the filename.
$ basename /home/dave/myscript
myscript
echo "Usage: ` basename $0 ` give me a file " exit 1 ...
If the above was part of a script called myscript, the output would be,
myscript: give me a file
The $0 is a special variable that holds the current full pathname of the script.
Read now
Unlock full access