How to Discover, From Inside a Bash Script, the Path the Script Is In - LinuxConfig.org

When you develop complex Bash scripts and start putting various scripts into a folder, where one script interacts with another by, for example, starting it, it quickly becomes necessary to ensure we know the path the script was started from, so we can start the other scripts with a fully qualified pathname. This is important because the first script may have been started from outside the script’s directory. We could have also done so by using a relative path, so even - somehow - reading the command that started the current script will not work.


This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-discover-from-inside-a-bash-script-the-path-the-script-is-in