How to run a bash script in terminal



I have Apple macOS Unix laptop. I am learning shell script. How do I open file created bash script with a text editor? How do I run file?


The procedure to run .sh files in terminal is as follows:

  1. Open the terminal application
  2. Give executable permission to your bash shell script using chmod command:
chmod +x /path/to/
chmod +x
  1. Run your shell script:
## in the current directory
## or use bash/sh as follows
bash /path/to/

I suggest you read:


Thank you
I tried to read it under the link you placed but I do not see where the problem is