How to run zsh script in specified folder? How to specify a folder to run a script:
zsh script_name.sh
Documents said that: "-s Force shell to read commands from the standard input. If the -s flag is not present and an argument is given, the first argument is taken to be the pathname of a script to execute." but it does not work.
What is the difference between zsh -c ~/path1/ script1.sh
(2 parameters) and zsh -c ~/path1/script1.sh
?
You should just open a subshell, Execute the following from zsh or bash (including the parentheses):
(cd ~/path1 && source script1.sh)
Note: If your script is written for zsh, name it script1.zsh
instead, since zsh syntax is not retro-compatible with old sh's.
This should work:
zsh -c "cd ~/path1 && ./script_name.sh"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With