ls -ltr|grep 'Mar 4'| awk '{print $9 }'|xargs zcat -fq |grep 12345
I'm now using this command to list the records that contain my numeric string how can i alos get this command to print the name of the file the strings were found in?
thanks
ls -ltr|grep 'Mar 4'| awk '{print $9 }'|xargs zcat -fq |grep 12345
I'm now using this command to list the records that contain my numeric string how can i alos get this command to print the name of the file the strings were found in?
thanks
Pass the -t
option to xargs
, causing it to print the command it is running (the zcat
command, including the filename) before running it. The command is printed to stderr, so it will not interfere with your pipe.
If you use zgrep instead of zcat+grep (which does the same), you do it like this option like this:
ls -ltr | grep 'Mar 4' | awk '{print $9}' | xargs zgrep 12345
$ find -maxdepth 1 -type f -newermt 'Mar 4' ! -newermt 'Mar 5' \
-execdir zgrep 12345 '{}' /dev/null ';'