grep -q 与 openssl 不起作用

Mat*_*teo 4 grep pipe openssl

如果我执行

openssl x509 -in ./somecert -text | grep SCTs
Run Code Online (Sandbox Code Playgroud)

我得到了预期的输出。如果我使用grep -q

openssl x509 -in ./somecert -text | grep -q SCTs
Run Code Online (Sandbox Code Playgroud)

我得到

unable to write certificate
139863258654608:error:09072007:PEM routines:PEM_write_bio:BUF lib:pem_lib.c:659:
Run Code Online (Sandbox Code Playgroud)

似乎grep是不接受管道输入......

我错过了什么?

Ral*_*edl 12

grep 正在接受管道输入,没有拒绝它的选项。

这里发生的是,grep -q一旦找到模式,就会关闭输入管道。消息来自,openssl因为它一旦关闭就无法写入管道。

在这种情况下,您应该添加到禁用写入证书-nooutopenssl选项。