Article 578VG Query about trimming and converting date from txt file

Query about trimming and converting date from txt file

by
JugaruGabi
from LinuxQuestions.org on (#578VG)
Hello,

So I am facing the following situation.
A txt file contains the following information:

Code:Owner: CN=servername28, O=YourSociety, DC=host, DC=com
Valid from: Fri Jul 10 21:52:55 CEST 2020 until: Sat Jan 16 18:00:00 CET 2021
Owner: CN=servernameA29, O=YourSociety, DC=host, DC=com
Valid from: Fri Jul 10 21:52:49 CEST 2020 until: Sat Jan 16 18:00:00 CET 2021
Owner: CN=servernameB30, O=YourSociety, DC=host, DC=com
Valid from: Fri Jul 10 21:52:58 CEST 2020 until: Sat Jan 16 18:00:00 CET 2021
Owner: CN=servernameA31, O=YourSociety, DC=host, DC=com
Valid from: Fri Jul 10 21:43:34 CEST 2020 until: Sat Jan 16 18:00:00 CET 2021
Owner: CN=servernameB32, O=YourSociety, DC=host, DC=com
Valid from: Fri Jul 10 21:46:36 CEST 2020 until: Sat Jan 16 18:00:00 CET 2021Now, I need to perform the following actions:
1. For each occurrence I just need to keep only "CN=servernameA/BXX, "
2. Remove the Valid from: <full date> until
3. Convert date from until from Sat Jan 16 18:00:00 CET 2021 to 16-01-2021
4. Move the resulted converted date after the "CN=servernameA/BXX, " on line above.

Am using a monitoring tool that reads the information from the txt file which is formatted this way and sends out notifications based on the expiration dates.

How could I achieve these things?latest?d=yIl2AUoC8zA latest?i=bPaQTHLc5RU:DQ8EipErHv4:F7zBnMy latest?i=bPaQTHLc5RU:DQ8EipErHv4:V_sGLiP latest?d=qj6IDK7rITs latest?i=bPaQTHLc5RU:DQ8EipErHv4:gIN9vFwbPaQTHLc5RU
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments