Tuesday, May 31, 2005

UNIX "basename" command

wats its doing PROGRAM_FILE=`basename $0 .sh`
in it a variable named PROGRAM_FILE is taken .now understand wats basename is doing.basename is an UNIX linux command to remove any unwanted parts.like as if we use command likeā€¦
$ basename my_script.sh.sh .sh
<< check for the intentional .sh which is written twice>>

wat it`ll do is that it will remove that extra .sh and will make it as my_script.sh.but if we give the command as
$basename my_script.sh .sh

wat will it do is that it`ll make it as only my script.look for the sample run from the system.
$ basename my_script.sh.sh .sh
my_script.sh
$
$
$ basename my_script.sh .sh
my_script

Labels:

0 Comments:

Post a Comment

<< Home