Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zcat pipe to grep

Tags:

grep

unix

zcat

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

I want to find all files modified on a certain date and then zcat them and search the fiels for a number string.

the above doesn't work because it searches the file name for the string not the file itself.

Any help?

M


1 Answers

Use xargs to run the grep on the filenames output by awk:

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

Or, I guess, run the rest of the pipe from awk itself.

like image 100
unwind Avatar answered Oct 31 '25 12:10

unwind