Problem
Often you want to set the working directory for a bash script to the folder that the bash script is located in.
Solution
Add the following line at the beginning of your script:
#!/bin/bash cd $(dirname $0)
References
Related articles
What do you think? Discuss, post comments, or ask questions at the end of this article [More about me]
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:
#!/bin/bash cd $(dirname $0)