Zcat pipe for grep

ls -ltr|grep 'Mar  4'| awk '{print $9 }'|zcat -fq |grep  12345

I want to find all the files modified on a specific date, then zcat them and do a cell search for a numeric string.

the above does not work, because it searches for the file name for the string, not the file itself.

Any help?

M

+3
source share
4 answers

Use xargsto run grep for awk output files:

ls -ltr | grep 'Mar 4' | awk '{print 9}' | xargs zcat -fq | grep 12345

Or, I suppose, run the rest of the channel from awk itself.

+2
source

Try using it instead find. And / or xargs.

+1
source

, zcat . xargs :

ls -ltr|grep 'Mar  4'| awk '{print $9 }'|xargs zcat -fq |grep  12345
+1

In addition to subtle answers about using xargseither, findyou can also get rid of the extra process by excluding zcatpiping on zgrepor grep -Z.

0
source

Source: https://habr.com/ru/post/1704568/


All Articles