我有这些字符串:
Certificate Name: domain1.com
Serial Number: 37aadb8fae7b908e1228c3e71
Domains: domain1.com www.domain1.com
Expiry Date: 2022-11-20 02:14:29+00:00 (VALID: 3 days)
Certificate Path: /etc/letsencrypt/live/domain1.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/domain1.com/privkey.pem
Certificate Name: www.domain2
Serial Number: 37aadb8fae7b908e1228c3e72
Domains: www.domain2
Expiry Date: 2021-10-19 02:15:45+00:00 (INVALID: EXPIRED)
Certificate Path: /etc/letsencrypt/live/www.domain2/fullchain.pem
Private Key Path: /etc/letsencrypt/live/www.domain2/privkey.pem
Certificate Name: domain3.com
Serial Number: 37aadb8fae7b908e1228c3e73
Domains: domain3.com www.domain3.com
Expiry Date: 2022-12-17 02:11:37+00:00 (VALID: 30 days)
Certificate Path: /etc/letsencrypt/live/domain3.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/domain3.com/privkey.pem
Certificate Name: domain4.com
Serial Number: 37aadb8fae7b908e1228c3e74
Domains: domain4.com www.domain4.com
Expiry Date: 2022-12-10 02:08:54+00:00 (VALID: 23 days)
Certificate Path: /etc/letsencrypt/live/domain4.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/domain4.com/privkey.pem
Certificate Name: domain5.com
Serial Number: 37aadb8fae7b908e1228c3e75
Domains: domain5.com www.domain5.com
Expiry Date: 2022-11-20 02:14:37+00:00 (VALID: 3 days)
Certificate Path: /etc/letsencrypt/live/domain5.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/domain5.com/privkey.pem
Certificate Name: domain6.com
Serial Number: 37aadb8fae7b908e1228c3e76
Domains: domain6.com www.domain6.com
Expiry Date: 2022-11-10 02:11:32+00:00 (INVALID: EXPIRED)
Certificate Path: /etc/letsencrypt/live/domain6.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/domain6.com/privkey.pem
Certificate Name: domain7.com
Serial Number: 37aadb8fae7b908e1228c3e77
Domains: domain7.com www.domain7.com
Expiry Date: 2020-05-31 23:50:48+00:00 (INVALID: EXPIRED)
Certificate Path: /etc/letsencrypt/live/domain7.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/domain7.com/privkey.pem
Certificate Name: domain8.com
Serial Number: 37aadb8fae7b908e1228c3e78
Domains: domain8.com www.domain8.com
Expiry Date: 2022-11-28 02:14:42+00:00 (VALID: 11 days)
Certificate Path: /etc/letsencrypt/live/domain8.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/domain8.com/privkey.pem
我习惯使用 sed,但我知道它只会逐行处理。
我已经尝试使用 awk 一段时间了,但由于我不熟悉它,所以我仍在苦苦挣扎。但是,我也愿意接受其他建议。
我只想查找关键字INVALID: EXPIRED
,然后在下一行返回域名,最后,它应该有这样的输出:
www.domain2
domain6.com
domain7.com
我认为这应该可以解决问题: