awk command finishing

1. awk default separated by a space, the contents of the specified location can be excised, usually used as follows (the file name is file.txt):

 Lines in the file contents: 12: 3 a 4:56 b

 awk '{print $ 1}' file.txt # output of the first content, i.e. '12: 3 '

 awk '{print $ NF}' file.txt # output of the last content, i.e. b

 

F 2 may also be used to specify delimiters, is used as follows (the specified colon):

    awk -F ":" '{print $ 1}' file.txt # output of the first content, i.e., '12'

 awk -F ":" '{print $ NF}' file.txt # output of the last contents, i.e., '56 b '

Guess you like

Origin www.cnblogs.com/quzq/p/12074954.html