I have a shell script /home/user1/bin/sh1, how can I print out the directory of this file inside the script.
Say I am in /home/user1/, then I run
/home/user1/bin/sh1
I need it to print out /home/user1/bin.
Thanks.
I have a shell script /home/user1/bin/sh1, how can I print out the directory of this file inside the script.
Say I am in /home/user1/, then I run
/home/user1/bin/sh1
I need it to print out /home/user1/bin.
Thanks.
Do you mean
ls /home/user1/bin
do u want only dir name ?? or the abolute path of the dir??
if the path: thn simply pwd command will work.
and if u want the dir name only
echo `pwd` | awk -F/ '{print $NF}'
will work
anchal.