I'm looking for some help in parsing a substring from the output of a command.
The output of the command looks like this (command is cerbot-auto certificates
and related to letsencrypt certificates:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
Certificate Name: amadev.domain1.com
Domains: amadev.domain1.com rcpdev8.domain1.com
Expiry Date: 2019-05-12 14:51:44+00:00 (VALID: 87 days)
Certificate Path: /etc/letsencrypt/live/amadev.domain1.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/amadev.domain1.com/privkey.pem
Certificate Name: amadev.domain2.com
Domains: amadev.domain2.com rcpdev8.domain2.com
Expiry Date: 2019-05-07 13:12:11+00:00 (VALID: 82 days)
Certificate Path: /etc/letsencrypt/live/amadev.domain2.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/amadev.domain2.com/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I'm looking to extract the certificate name and the domains but am struggling the with the bash substring commands. I think I should be able to get what I need using cut and then manipulating that result but I haven't been successful yet.
It doesn't matter to me if I end up with an array of some sort with all values or if the code loops and does each one individually overwriting the previous but I need something that ends up with variables holding values that look like this:
certificate="amadev.domain1.com"
domains="amadev.domain1.com,rcpdev8.domain1.com"
Thanks in advance.