【问题标题】:Linux/OpenSSL:Send find output to opensslLinux/OpenSSL:将查找输出发送到 openssl
【发布时间】:2011-02-14 09:36:59
【问题描述】:

我正在尝试将 find 命令的输出发送到 OpenSSL,以了解证书何时过期。

这会找到文件

find . -name \*.pem -type f

这会生成我想要的证书信息

openssl x509 -in certname.pem -noout -enddate

我可以合并这两个吗?

感谢您的帮助。

【问题讨论】:

    标签: linux bash find openssl x509certificate


    【解决方案1】:
    find . -name \*.pem -type f -execdir openssl x509 -in {} -noout -enddate \;
    

    【讨论】:

    【解决方案2】:

    正如对 find 的一般评论:如果您获取 find 的输出并将其通过管道传输到 xargs 并让其运行命令,您的命令将运行得快得多。问题是 find 会为每个匹配的文件生成一个新命令,这非常慢,但是如果您可以将多个参数传递给同一个命令(就像 xargs 一样),您可以保存所有这些 fork 和上下文切换。它适用于 grep 等命令。

    【讨论】:

    • 这是我的第一直觉,但除了 enddate 输出之外,我无法打印证书名称。我想把它们做成一张小桌子。
    猜你喜欢
    • 1970-01-01
    • 2018-10-23
    • 1970-01-01
    • 2011-07-30
    • 1970-01-01
    • 2020-06-12
    • 1970-01-01
    • 2018-02-06
    • 2013-04-21
    相关资源
    最近更新 更多