openssl:如何在控制台中禁用“写入RSA密钥”消息

Art*_*nin 4 bash shell openssl

有什么方法可以禁用控制台消息“写入RSA密钥”吗?

$ openssl rsa -pubout -outform DER -inform PEM -in /tmp/res/chrome.pem -out 1 > /dev/null 
writing RSA key
$ openssl rsa -pubout -outform DER -inform PEM -in /tmp/res/chrome.pem -out 1
writing RSA key
$ openssl rsa -pubout -outform DER -inform PEM -in /tmp/res/chrome.pem > /dev/null
writing RSA key
Run Code Online (Sandbox Code Playgroud)

我尝试了这些命令,结果相同:(

Ans*_*ers 5

运行命令with将strace显示消息已写入STDERR

write(2, "writing RSA key\n", 16)       = 16
      ^
Run Code Online (Sandbox Code Playgroud)

因此您必须重定向,STDERR而不是STDOUT

openssl rsa -pubout ... 2>/dev/null
Run Code Online (Sandbox Code Playgroud)