我的数据如下所示:
STX=ANAA:1+5013546100917:KELLOGG COMPANY (GB) LIMITED+5000119000006:TESCO STORES PLC+160811:134338+63010+PIONEER+INVFIL+B'
MHD=1+INVFIL:9'
TYP=0700+INVOICES'
SDT=5013546100917:12191+KELLOGG COMPANY (GB) LIMITED+THE KELLOGG BUILDING:TALBOT ROAD:MANCHESTER::M16 OPU+151194288'
CDT=5000119000006:5000119000006+TESCO STORES PLC+BOUGHT LEDGER DEPARTMRENT:TESCO HOUSE:PO BOX 506:CARDIFF:CF4 4TS+220430231'
FIL=9476+1+160811'
FDT=160313+160315'
MTR=7'
MHD=2+INVOIC:9'
CLO=5000119008510:0100851:4420009+TESCO (CO ANTRIM)+KILBEGS ROAD:BALLYMENA ROAD:ANTRIM:AT:BT41 4NN'
IRF=92349489+160314+160314'
我希望GREP获得“FIL =”和“IRF =”并将其打印出来以查看结果。
我尝试了各种选项,但都没有效果!
zgrep -i 'FIL=\|IRF=\|' `zgrep -il "5000119000006" *201609*`
zgrep "FIL=|IRF=" `zgrep -il "50001190000006" *201609*'
答案 0 :(得分:0)
如果文件是压缩的:
zegrep 'FIL=|IRF=' *gz
如果文件是常规文件(非压缩):
egrep 'FIL=|IRF=' *
所以你应该这样试试:
50001190000006
如果文件中存在数据,则从文件中搜索FIL=|IRF=
zgrep -q '5000119000006' test.file;if [ $? -eq 0 ];then egrep 'FIL=|IRF=' test.file; fi
FIL=9476+1+160811'
IRF=92349489+160314+160314'
将test.file
替换为201611
(系统中的实际文件名)