Sh equivalent to __FILE__

Is there an equivalent to sh __FILE__ to tell me the path to the executable? POSIX solutions are preferred, bash is acceptable, thanks.

+7
file php shell
source share
3 answers

Try using $0 .

+5
source share

To solve bash script

Getting the bash script source directory from the inside

+1
source share

Just a thought:

 #!/usr/bin/env bash # "$0" will expand to the name of the script, as called from the command line readlink -f $0 
0
source share

All Articles