I want to have a bash-script discover its own path.
The background is that I have a script called process_scanned_text.sh
, which itself uses the script curves
.
I put curves
in the same directory as process_scanned_text.sh
. I created a symlink to process_scanned_text.sh
in my ~/bin
folder. Now I don't know how to correctly call the curves
script. As it is not in $PATH
, I need to specify it's path. Using dot as path is not correct as this points to the directory from which I call process_scanned_text.sh
. Using dirname $0
does not work either as this points to my bin
folder (where the symlink is).
dirname $(readlink -f $0)
– Mark Plotnick Dec 22 '14 at 19:23