Saturday, 28 January 2012


 basename is used to get the name of the file given its complete path including the file.
It is also  helpful to access the name of  a script within it.

Ex ample1)
To get the name of a file from its complete path.
/home/gj876$ echo $CGI_PATH
/home/gj876$ basename $CGI_PATH

Suppose a script “/home/scripts/” is called from   another script with its complete path,then to access the  base filename of  “/home/scripts/”, use
File_name=`basename $0`
echo $File_name

the output will be

No comments:

Post a Comment