Follow this to execute a script in a different directory in Linux.
I had a script in
~/Documents/scripts/awesome-script.sh and wanted to run it inside a different directory
You can use parentheses to create a subshell. Once the command is completed, the subshell will close, such as...
$ (cd ~/Documents/images/awesome-images/ && ~/Documents/scripts/awesome-script.sh)
This is how it works:
- Use parentheses to create a subshell
- If this command is successful then
- Execute the script located in
- When this command is executed. Close the subshell
If you have questions or comments please add them below