简体   繁体   中英

AWK filter data by characters

A data set like below:

07021201180934221NJL B2018   12X 15253                                                                                                               030C       000000.299
07021201180934231NSL B2018   12X 15253                                                                                                               030C        00000.014
07021201180941061NNL B2018                                                                                                                           030C       000000.288

Questions are:

  1. The characters in the first string "120118" means date "ddmmyy", how could I filter rows according to date characters using awk?

  2. The characters in first string "NJL" or "NSL" or "NNL" means data type, what awk command to filter lines according to those three characters?

  3. The third column could be some description like "12X 15253" or empty, how could I filter data out if the column is empty?

Thanks in advance!

该脚本具有所有条件

$ awk 'substr($1,5,6)==120118 && substr($1,length($1)-2)=="NNL" && $3$4==""' file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM