bash-tutorial/tutorial/run_bash_script.org

46 lines
757 B
Org Mode
Raw Normal View History

2022-07-03 21:06:29 +02:00
* Run a bash script
** Write script
After writing, save the file with '.sh' extension. This script will
echo the words within quotes
#+begin_src bash
#!/bin/bash
echo "Hellow hu-hu"
#+end_src
#+RESULTS:
: Hellow hu-hu
** Option a: make it executable
Use the command "chmod" to change permissions for the file
#+begin_example bash
chmod +x script.sh
#+end_example
Then, execute
#+begin_example bash
./script.sh
#+end_example
** Option b: run from terminal
#+begin_example bash
bash script.sh
#+end_example
Or
#+begin_example bash
sh script.sh
#+end_example
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