operation | what | code |
---|---|---|
string | variable equal to “xyz“ | if [ $STR == “xyz” ] |
variable unequal to “xyz“ | if [ $STR != “xyz” ] | |
variable contains substring “xyz“ | if [[ $STR =~ “xyz” ]] | |
variable is in list “abc” or “def” (or …) | if [[ $STR =~ ^(“abc”|“def”)$ ]] | |
integer | variable equal to n | if [ $STR -eq n ] |
file | “node” exists (whatever type i.e. file, folder, …) | if [ -e “node” ] |
regular “filename” exists | if [ -f “filename” ] | |
create unique temporary file | touch /tmp/$$.tmp | |
find file “filename” with numerically largest extension in folder | ls -1d “filename.*” | cut -d ”.” -f 2 | sort -rg > /tmp/$$.tmp MAX=$(head -n 1 /tmp/$$.tmp) |
|
execution | result of command execution | RSLT=$? |
being root | if ($(id -u) -eq 0)) |
work in progress