Cut command limitations
DF-H | cut-D ""-F 5/etc/passwd
The cut command cannot correctly intercept the content with spaces as the separator.
Awk format
Awk 'condition 1 {Action 1} condition 2 {Action 2 }... 'Filename'
Condition (pattern) [relational expressions are generally used as conditions]:
X> 10 determine whether variable X is greater than 10
X> = 10 is greater than or equal
X <= 10 is less than or equal
Action ):
Formatted output: printf, print [\ n will be automatically added]
Process control statement: If/
Percentage of truncated/partitioned data
DF-H | grep sda2 | awk '{print $5}' | cut-D %-F1
Begin
Awk 'in in {printf "this is a test script \ n"} {print $2 "\ t" $5} 'student.txt # first run the command followed by begin
Awk 'in in {FS = ":"} {print $1 "\ t" $3} '/etc/passwd # display the specified separator
Awk-F: '{print $1 "\ t" $3}'/etc/passwd # Same as before
End
CAT/etc/passwd | grep/bin/bash | awk-F: 'End {print "the end... "} {print $1" \ t "$3} '# print the End Content Before the command ends.
Relational operators
Cat student.txt | grep-V name | awk '$3> = 80 {print $2 }'
Awk '$3> = 80 {print $2}' student.txt | grep-V name # An error may occur.
Analysis of awk usage