User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







bash:how_to:tests

bash: "How To" ... utilize tests

operationwhatcode
stringvariable equal to “xyzif [ $STR == “xyz” ]
variable unequal to “xyzif [ $STR != “xyz” ]
variable contains substring “xyzif [[ $STR =~ “xyz” ]]
variable is in list “abc” or “def” (or …)if [[ $STR =~ ^(“abc”|“def”)$ ]]
integervariable equal to nif [ $STR -eq n ]
filenode” exists
(whatever type i.e. file, folder, …)
if [ -e “node” ]
regular “filename” existsif [ -f “filename” ]
create unique temporary filetouch /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)
executionresult of command executionRSLT=$?
being rootif ($(id -u) -eq 0))

work in progress

advertising
bash/how_to/tests.txt · Last modified: 2018/08/03 06:24 by Rob Stroess

Impressum Datenschutz