FIT3042 Final: Bash Scripting Cheat Sheet
Bash Scripting
How to run a .sh file
source filename.sh
sh file
#!/bin/bash on the top
Special Variables
Setting a Variable
myvar=Hello
myvar=’hello world’
Arithmetic
let
let a=5+4
Echo $a ( prints out 9)
expr
expr 5 + 4 output: 9
expr “5 + 4” output: 5 + 4
a=$( expr 10 - 3)
echo $a output: 7