User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

Q&A is closed


bash: "How To" ... utilize tests

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

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
bash/how_to/tests.txt · Last modified: 2024/02/16 01:04 (external edit)

Impressum Datenschutz