bash-tutorial/tutorial/run_bash_script.org

757 B

Run a bash script

Write script

After writing, save the file with '.sh' extension. This script will echo the words within quotes

  #!/bin/bash
  echo "Hellow hu-hu"
Hellow hu-hu

Option a: make it executable

Use the command "chmod" to change permissions for the file

 chmod +x script.sh

Then, execute

./script.sh

Option b: run from terminal

bash script.sh

Or

sh script.sh

PS: to execute the script from any place in the machine include the script in a directory that can be read from $PATH

Option c: run from graphical interface