Conditions
= equals applies To: integer or string comparison if in [], only the string
! = is not equal to: integer or string comparison if in [], only the string
-eq equals applies To: integer comparison
-ne not equal to: integer comparison
-lt less than applied to: integer comparison
-GT greater than applied: integer comparison
-le less than or equal to: integer comparison
-ge greater than or equal to: integer comparison
-A both are established (and) logical Expressions –a logical expressions
-O unilateral formation (or) logical expression –o logical expression
-Z Empty string
-N Non-empty string
-F Common! Detect if "Archive" exists eg:if [-f filename]
-D Common! Detects if the directory exists
-B Detection is a "block file"
-C detection is a "character file"
-S detection is a "socket tag file"
-L detection is a "symbolic Link's profile"
-E detects if "something" exists!
2. About the program's Logical volume label!
-g detection is owned by the program performed by the GID
-O detection is owned by the program executed by the UID
-P detects if a name pipe or FIFO is being transmitted between programs (to be honest, this is not a good idea!) )
3. About the property of the file detection!
-R to detect if a property is readable
-W detection is a property that can be written
-X detect whether the property is executable
-S detection is a "non-blank file"
-U detect if a property with "SUID"
-G detection for properties with "SGID"
-K Detect if there is a property of "sticky bit"
4. Judgment and comparison between two files; for example [Test file1-nt file2]
-nt the first file is newer than the second one.
-ot The first file is older than the second one.
-ef The first file is the same file as the second file (link and other files)
5. Logical "and" "or (OR)"
The meaning of && logic
|| The meaning of a logical OR
For i in ' seq 5 6 '
Do
echo "for" $i
Done
Count=0
Until [$count-GT 1]
Do
Count= ' expr $count + 1 '
echo "Until" $count
Done
While [$count-GT 1]
Do
count= ' Expr $count-1 '
echo "while" $count
Done
if [1 = 1] && [2-eq 2]; Then
echo "If"
elif [1 = 1]; Then
echo "Elif"
Else
echo "Else"
Fi
echo "AAA123BBB" | Awk-f[0-9] ' {print $ ': ' $ '-' $4;} '
Linux Shell Common syntax