Hi all,
Help me, please
How do I find the directory you run the script?
but, it is Linux way - it is do not work in FreeBSD.
I have: ~/scripts/test/run.sh
It is Ok, but:
It is not good!
This is understandable, the command "pwd" displays the path where the current terminal.
The script is in fact in ~/scripts/test/.
Help me, please.
Help me, please
How do I find the directory you run the script?
Code:
#!/bin/sh
#
filename=`readlink -e "${0}"`
whereami=`dirname "${filename}"`
echo "${whereami}"
but, it is Linux way - it is do not work in FreeBSD.
Code:
#!/bin/sh
#
whereami=`pwd`
echo "${whereami}"
I have: ~/scripts/test/run.sh
Code:
# cd ~/scripts/test/
# sh run.sh
[B]/usr/home/<USERNAME>/scripts/test/[/B]
It is Ok, but:
Code:
# cd ~/scripts/
# sh test/run.sh
[B]/usr/home/<USERNAME>/scripts/[/B]
This is understandable, the command "pwd" displays the path where the current terminal.
The script is in fact in ~/scripts/test/.
Help me, please.