根据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.
Run Code Online (Sandbox Code Playgroud)
如果我使用zgrep -h dhclient /var/log/syslog.*
,我仍然会看到文件名。如果我使用zgrep --no-filename ...
,一切都很好。
这是怎么回事?
我正在使用 Ubuntu 12.04.5 LTS。
该zgrep
命令由gzip
包提供(根据dpkg -S zgrep
);-h
根据 gzip 更改日志(来自http://ftp.gnu.org/gnu/gzip/),在 2010 年 9 月 5 日添加了对switch 的支持:
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>.
Run Code Online (Sandbox Code Playgroud)
Ubuntu 包和上游 Debian 包有一个相关的变化。该变更日志指出这是一个“回归”。我不清楚实际情况是否如此,但缺少的开关在 Ubuntu 14.04 LTS 中工作正常。
给steeldriver 的帽子提示,用于查找 Debian/Ubuntu 更新日志。