HI,
Can anyone explain to me how does the following command work - >
current_dir=`cd \`/usr/bin/dirname $0\` && pwd`
Regards,
Ranga
HI,
Can anyone explain to me how does the following command work - >
current_dir=`cd \`/usr/bin/dirname $0\` && pwd`
Regards,
Ranga
$ cat spt
echo $0
current_dir=`cd \`/usr/bin/dirname $0\` && pwd`
echo "current_dir="$current_dir
$ /db2home/training/anbu/spt
/db2home/training/anbu/spt
current_dir=/db2home/training/anbu
cd \`/usr/bin/dirname $0\` cd to script directory
pwd assign the directory to current_dir where script resides.
Instead of above code you can use this
current_dir=`/usr/bin/dirname $0`
Hi ,
Thanks for your reply. One more doubt
Does �cd \`/usr/bin/dirname $0\` cd to script directory� will the same change the directory or jus gives u the directory name?
Regards,
Ranga
cd \`/usr/bin/dirname $0\` just change directory
In the following code this cd is done within `..` which will open new shell and change directory. So if you come out this line you will be in the same directory as before executing this line.
current_dir=`cd \`/usr/bin/dirname $0\` && pwd`