A few things for you...
⟫ Wright your script with extension '.sh'
⟫ Start your script with #!/bin/bash (or #!/bin/'your shell_type)
⟫ Give your shell execute permission (sudo chmod 755)
⟫ There is three way to execue a shell script ...
bash shell_script_name.sh
./shell_script_name.sh
path/of/your/shell/script/shell_script_name.sh