Detailed awk

awk is a precise finding and progressive process, but can not modify the file.

awk use:

Pre-command | awk options (condition) command

Common options are [-F] defined delimiter 

Instruction print  print output results  BEGIN start END End 

Built-in variables   $ 1 $ 2 $ 3 ..... different column    $ 0 for all columns   NR NF line number column number 

 awk '{print}' file name     which is the output of view as all lines and cat

 awk '{print $ 1}' file name     which is the output of the first column for all rows

 awk '{print $ 2}' file name which is the output of the second column for all aircraft

 awk '{print $ 1, $ 2}' file name which is the output of all the rows 2-3 column es

 awk '{print $ 0}' output file name that all lines are generally used with other variables

 awk -F (defined separator) '{print $ 1}' file name is defined as a colon delimiter, a first display column

 awk -F (defined separator) '{print $ 1 "ha"}' file name display variable plus constant

  awk -F: '{print NR, NF}' filename colon delimiters, and the total number of display line numbers and number sequence

Published 14 original articles · won praise 0 · Views 201

Guess you like

Origin blog.csdn.net/nbnbnb_/article/details/103897861
awk