Awk
Format: awk [option] ' Condition 1{action 1} Condition 2{action 2} ... ' Filename
Conditions: Regular expressions; logical judgments
Action: Formatted output, flow control statement
Options:
-f Specifies the delimiter
Variable:
$ ... The first column
NR line number
NF Column number
FileName File name
Conditions:
/Regular expression/filter out rows that match regular expressions
Logical judgement ~,!~ matching regular expression
==,!=,<,> Logical Judgment Expression
Cases:
Awk-f ': ' {print nr,nf,$1} ' Zz_test.txt
Awk-f ': ' {if ($3>100) print nr,$1} ' passwd
Awk-f ': '/false/{print ' line: "NR," USER: "$ ' passwd"
Awk-f ': ' $1~/^m.*/{print $ ' passwd
Awk-f ': ' $3>50{print $ ' passwd
ll-a | awk ' Begin{size=0}{size=size+$5}end{print ' Siez is ' size} '
This article from "Sevenot" blog, reproduced please contact the author!
Linux Text Processing command "awk" simple solution