I have a file called execute.command. When I execute it by opening it. It runs from my users folder. I would like it to run in the folder where it is located. is that possible?
Asked
Active
Viewed 44 times
2 Answers
2
You must change the script to change working directory to script-location directory:
#!/bin/bash
cd "$(dirname "$0")"
More answers here : Bash script: set current working directory to the directory of the script
0
I added cd dirname $0
to the top of the command line. This will cd you into the correct folder. Here are more details.
http://hints.macworld.com/article.php?story=20041217111834902

Himmators
- 14,278
- 36
- 132
- 223