Running .sh scripts in Git Bash
Solution 1:
Let's say you have a script script.sh
. To run it (using Git Bash), you do the following: [a] Add a "sh-bang" line on the first line (e.g. #!/bin/bash
) and then [b]:
# Use ./ (or any valid dir spec):
./script.sh
Note: chmod +x
does nothing to a script's executability on Git Bash. It won't hurt to run it, but it won't accomplish anything either.
Solution 2:
#!/usr/bin/env sh
this is how git bash knows a file is executable. chmod a+x
does nothing in gitbash. (Note: any "she-bang" will work, e.g. #!/bin/bash
, etc.)
Solution 3:
If you wish to execute a script file from the git bash prompt on Windows, just precede the script file with sh
sh my_awesome_script.sh