Is there a way to get the script directory regardless of change in current directory that occurred during script execution.
echo $(dirname "$(readlink -f "$0")") cd /tmp echo $(dirname "$(readlink -f "$0")") /home/user/test /tmp In the example above, I need /home/user/test both times, without storing it to a variable.