dirname [file]
: get path of a filepushd [directory]
: push cwd to stack, set cwd to directorypopd
: pop stack to cwdexit [status]
: terminate a scriptset -e
: terminate script if any cmds exits with errorA || B
: exec B only if A failsVAR=VALUE
: set variable${VAR}
: get variable$VAR
: get variableVAR=$(CMD)
: store result of cmd exec in variable$0
: first arg of script = name of script$@
: cmd args of script$#
: num of args$?
: exit status of last command executed${BASH_SOURCE}
: filename+path of the current script being executed#!/bin/bash
: Specifies which shell should be used to execute the script1 2 3 4 5 6 7 |
|
Always enclose variable with " "
!
VAR == "debug"
: == string"$VAR" != "string"
: != string-eq 0
: == value! -eq 0
: != value-gt 0
: > value-v VAR
: variable is set/exists-z VAR
: variable is unset/empty-n "$VAR"
: string in variable is empty-f "file.txt"
: file exists