SHELL example 1. if statement
2. interactive selection
3. cyclic judgment
4. numeric operators
5 ,............
If statement format:
If [condition]
Then
Command
Else
Command
Fi
Interactive selection (N can be *)
Echo-e "prompt language, followed by a cursor for input"/c
Read VAR
Case $ VAR in
Y)
Command
;;
N)
Command
;;
Esac
Perform a cyclic check on the condition. if the condition is true, the check will be processed; otherwise, the check will continue.
A = 1
While ["$ a" = "1"]
Do
Fileno = 'ls-l/list/filename * | wc-L'
If ["$ fileno" = "10"]
Then
A = 10
Command
Else
A = 1
Sleep 300
Fi
Done
Grep-v www filename filtering does not contain
Grep www filename filtering inclusion
The uniq-u filter does not have the same row
Uniq-d filter has the same row
Sort sorting
Paste-d ";" filename1 filename2 merge and separate the files.
If ["a" = "10"] # a = 10
["A"-ne "10"] same line
[-S filename] the file size is greater than 0
-S file size greater than 0 returns true
-D is a directory that returns true
-E: the file or directory exists, and the returned result is true.
-If g exists, SGID returns true.
-H: The file is the connection file and returns true
-K files are sticky bits to return true
-Returns true if the r file or directory exists and is readable.
-W: Returns true if a file or directory exists and can be written.
-The u file is SUID and returns true
-X file is executable and returns true
-Eq equals
-Ne is not equal
-Lt is less
-Le is less than or equal
-Gt greater
-Ge is greater than or equal
2*3 + 4 | bc calculates the previous data
Ping-w 2 www.163.com test 2 twice
Last Command result judgment
$? = 0 true
$? = 1 is false
Add parameters to SHELL
XXXX = 'echo | wc-C'
Cat $ HOME/list/file.txt 1>/dev/null 2>/dev/null
OK = $?
If ["" = ""] | ["$ XXXX"-lt "4"] | ["$ OK"-ne "0"]
Then
Echo "inputs are not input. the input number is not equal to 3. File.txt does not exist. please enter them again"
Exit
Fi
One loop check
Line = 1
For I in 'cat BB'
Do
Qq = 'echo "scale = 2; $ I * 100" | bc | awk-F. '{print }''
If ["$ qq"-ge "75"]
Then
Sed-n "$ line" p temp.1> bad.1
Fi
Line = 'expr $ line + 1' ### add 1 at a time
Done