What do you think? Discuss, post comments, or ask questions at the end of this article [More about me]

Skip to end of metadata
Go to start of metadata


Often you want to set the working directory for a bash script to the folder that the bash script is located in.


Add the following line at the beginning of your script:


cd $(dirname $0)


  1. https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself