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 test.sh 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/script.sh
chmod +x test.sh
  1. Run your shell script:
/path/to/script.sh
## in the current directory
./test.sh
## or use bash/sh as follows
sh test.sh
bash /path/to/script.sh

I suggest you read:

2 Likes

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