Awk 'nf'
Filter blank rows
Awk '! A [$0] ++'
Filter duplicate rows
Awk 'nf-= 2'
Filter out the last two columns
Awk 'a =! A'
Print odd rows
Awk '! (A =! A )'
Print even rows
Awk 'end {print Nr }'
Simulate WC-l
Awk 'in in {print "'\''"}'
Print single quotes. The quotation marks are followed by single quotes, and single quotes.
Awk 'in in {print "\""}'
Double quotation marks are printed, followed by double quotation marks.
Awk 'in in {rs = ""; FS = "\ n"} {print NF }'
Calculates the number of lines of each text segment based on an empty behavior.
Awk-VRS = "\ n"-vofs = "" '$1 = $1'
Based on the segmentation standard of each text segment of an empty behavior, a text segment is integrated into one line.
Awk '{A = $2; $2 = $4; $4 = A} 1'
Column exchange
Awk '/[^! -~] /'
Print rows containing Chinese Characters
Awk '/[! -~] /'
This will not be explained at the meeting. It is best to execute lang = C before executing this column.
Awk 'nf {A = $ NF} end {print }'
Print the last word in the last line
Awk '{print $1> "file"}' file
Only keep the first column of the file (Dangerous to directly modify the file content)
This article from the "lisp O & M path" blog, please be sure to keep this source http://lspgyy.blog.51cto.com/5264172/1543687
Awk practical tips