Learning bash scripting for automation based on this tutorial.
Making an executable and compiling through:
chmod +x <filename>.sh
./<filename>.sh
Checking default interpreter with:
echo $SHELL
Define shell interpreter explicitly with:
#!/bin/bash
Alternative to execute a bash script is with:
$ bash <filename>.sh
In this way the content of the file is directly loaded and interpreted as a script.
- Navigating to the previous location you were with
cd - - Any command output can be recorded in a file through
>, for exampleecho "Hello World" > text.txtwill create text.txt file with "Hello World" - Assigning variables happens as usual but you cannot use spaces
a = 8is not valid buta=8is - Calling variables is done with "$" ->
echo $awill display a's value