根据man grep的说法:
-h, --no-filename
Suppress the prefixing of file names on output. This is the
default when there is only one file (or only standard input) to
search.如果我使用zgrep -h dhclient /var/log/syslog.*,我仍然可以看到文件名。如果我使用zgrep --no-filename ...,一切都很好。
到底怎么回事?
我正在使用Ubuntu12.04.5LTS。
发布于 2016-10-06 17:06:45
zgrep命令由gzip包提供(根据dpkg -S zgrep);根据gzip变更量(来自http://ftp.gnu.org/gnu/gzip/),在2010-09-05年间添加了对-h交换机的支持:
2010-09-15 Paul Eggert <eggert@cs.ucla.edu>
zgrep: fix parsing of -Eh options
* zgrep.in: Update list of single-letter options to match what's
in GNU grep. Add -h as an alias for --no-filename. Bug reported
by Vladimir Sidorenko in
<http://lists.gnu.org/archive/html/bug-gzip/2010-09/msg00007.html>.有一个相关的更改为Ubuntu包和上游Debian包。这一变化表明这是一种“倒退”。我不清楚是否真的是这样,但是缺少的开关在Ubuntu14.04LTS中工作得很好。
感谢斯蒂尔·德里弗找到Debian/Ubuntu。
https://unix.stackexchange.com/questions/314781
复制相似问题