learning shell get script absolute path (3)
Shell get script absolute path
【Purpose】
Get shell script absolute path
【Eevironment】
Ubuntu 16.04 bash env
【Procdeure】
Source code:
1 #!/bin/bash 2 echo "$(dirname "$(realpath "${BASH_SOURCE}")")" 3 echo "$(realpath "${BASH_SOURCE}")" 4 echo "${BASH_SOURCE}"
Test method:
vmuser@vmuser-virtual-machine:~/panzidong/shell$ ./tmp.sh
/home/vmuser/panzidong/shell
/home/vmuser/panzidong/shell/tmp.sh
./tmp.sh