我对你的情况回答是这样的命令:
ls /etc/pki/tls/certs/cert*.pem | xargs -L1 openssl x509 -noout -enddate -in
说明
在第一步中,我把我的证件,我想分析的列表。例如在我的情况下,它可能是这样的:
[[email protected] certs]# ls -1 */*.crt
ewsport.org/ewsport.org.crt
hxpro.cz/hxpro.crt
jaguars.cz/jaguars.crt
koudelka.photography/koudelka.photography.crt
unicycle-hockey.cz/unicycle-hockey.cz.crt
unipragga.cz/unipragga.cz.crt
下一步,我想要从他们每个人获得到期日期。
[[email protected] certs]# openssl x509 -noout -enddate -in hxpro.cz/hxpro.crt
notAfter=Apr 24 11:29:21 2017 GMT
现在我可以使用xargs将第一条命令的输出发送到第二条命令。
[[email protected] certs]# ls -1 */*.crt | xargs -L1 openssl x509 -noout -enddate -in
notAfter=Mar 31 15:08:20 2017 GMT
notAfter=Apr 24 11:29:21 2017 GMT
notAfter=Mar 23 21:23:42 2017 GMT
notAfter=Apr 24 11:50:32 2017 GMT
notAfter=Dec 11 16:32:41 2016 GMT
notAfter=Mar 20 19:44:17 2017 GMT
我使用了选项-L1,因为openssl命令只需要一个-in文件作为输入。
我已经设法使用一个文件名数组遍历for循环。如果有更好的工作,请分享。谢谢 – Zeeshan 2012-04-05 15:51:01