You can't just use ../../<DIRS>
because ..
will change depending on where you are, that is what $PWD
is; rather than where the script using ..
is.
Using realpath
and dirname
startdir="$(dirname "$(realpath "$0")")"
script="2.sh"
"$startdir"/../../"$script"
Using the absolute path
If you don't have access to realpath
and dirname
or don't want to use them: if you know that the location of 2.sh
and 1.sh
will never change, then you should fine using an absolute path to 2.sh
"$HOME"/code/scripts/2.sh