【发布时间】:2018-05-21 04:04:58
【问题描述】:
完全相同的命令:
man curl | grep -Pzo 'EXIT CODES(.|\n)*AUTHORS' | grep ' 6 '
有时会给出预期的输出:
6 Couldn't resolve host. The given remote host was not resolved.
有时会报错:
Binary file (standard input) matches
例如:
$ man curl | grep -Pzo 'EXIT CODES(.|\n)*AUTHORS' | grep ' 6 '
6 Couldn't resolve host. The given remote host was not resolved.
$ man curl | grep -Pzo 'EXIT CODES(.|\n)*AUTHORS' | grep ' 6 '
Binary file (standard input) matches
$ man curl | grep -Pzo 'EXIT CODES(.|\n)*AUTHORS' | grep ' 6 '
Binary file (standard input) matches
$ man curl | grep -Pzo 'EXIT CODES(.|\n)*AUTHORS' | grep ' 6 '
6 Couldn't resolve host. The given remote host was not resolved.
相关包的版本:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial
$ grep --version
grep (GNU grep) 2.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
$ man --version
man 2.7.5
$ curl --version
curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets
我真的为这个而摸不着头脑。
我通过将-a 标志放入我的 grep 中解决了我的问题:man curl | grep -Pzoa 'EXIT CODES(.|\n)*AUTHORS' | grep -a ' 6 '
但我真的很困惑为什么有时它只会出错?...
【问题讨论】:
标签: bash shell curl grep manpage