bash - How Can I Grep For Two Different Strings and Print Them? -
my data looks below:
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'
and want grep "fil=" , "irf=" , print them out see results.
i have tried various options none of them work!
zgrep -i 'fil=\|irf=\|' `zgrep -il "5000119000006" *201609*` zgrep "fil=|irf=" `zgrep -il "50001190000006" *201609*'
if file zipped:
zegrep 'fil=|irf=' *gz
if files regular files (not zipped):
egrep 'fil=|irf=' *
so should try this:
- first filter data
50001190000006
if data present in file search
fil=|irf=
filezgrep -q '5000119000006' test.file;if [ $? -eq 0 ];then egrep 'fil=|irf=' test.file; fi fil=9476+1+160811' irf=92349489+160314+160314'
replace test.file
201611
(actual file name in system)
Comments
Post a Comment