[英]zcat to grep with file name
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谢谢
If you use zgrep instead of zcat+grep (which does the same), you do it like this option like this:如果你使用zgrep而不是 zcat+grep (它做同样的事情),你这样做像这样的选项:
ls -ltr | grep 'Mar 4' | awk '{print $9}' | xargs zgrep 12345
Pass the -t
option to xargs
, causing it to print the command it is running (the zcat
command, including the filename) before running it.将
-t
选项传递给xargs
,使其在运行之前打印正在运行的命令( zcat
命令,包括文件名)。 The command is printed to stderr, so it will not interfere with your pipe.该命令会打印到 stderr,因此它不会干扰您的 pipe。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.