comp.unix.questions
Kingsley Nwosu
nwosuck at aix.aix.kingston.ibm.com
Fri Oct 12 02:38:03 AEST 1990
In article <9434 at uudell.dell.com>, root at ninja.dell.com (Randy Davis) writes:
> In article <1990Sep7.152354.9439 at ecn.purdue.edu> patkar at helium.ecn.purdue.edu (The Silent Dodo) writes:
> |I have a question about shell scripts. How can a shell script
> |(sh or csh) find out its own file name? Actually, I need to
> |know only the directory in which it resides.
>
> Hmmmmm..... Off the top of my head, how about this?:
>
> COMMAND=`basename $0`
> DIR=`type $COMMAND | sed -e 's:^.* /:/:' -e "s:/$COMMAND$::"`
> echo "Parent directory of \"$COMMAND\" is \"$DIR\""
>
Why not do:
echo "Directory name is `dirname $0`"
in sh.
Kingsley Nwosu ...uunet!ibmps2!aix!nwosuck
IBM AIX Dev., Dept. 83HA/572, |
Neighborhood Rd, Kingston, |"Advice to those about to get married: Don't!"
NY 12401. |
More information about the Comp.unix.questions
mailing list