0

Could someone help me with a Shell Script OR a perl script which could read the below INPUT File and print output in format listed below.

The logic I am looking for is to read each block within the asterisk line, then search for "until:". If the date of "until:" is less than OR equal to current date, then print the "Alias Name".

START OF INPUT FILE (NOTE INPUT FILE IS IN BELOW FORMAT INCLUDING ASTERISKS LINES)

*****************************************************************************

Alias Name: sdtest1102
Type: CertificateEntry
Subject: CN=sdtest1102,OU=sdtest1102,O=sdtest1102,L=sdtest1102,ST=CO,C=US
Issuer: CN=sdtest1102,OU=sdtest1102,O=sdtest1102,L=sdtest1102,ST=CO,C=US
Serial Number: 012C17d47F82E
Valid from: Thu Nov 04 10:26:21 EDT 2010 until: Tue Nov 03 10:26:21 EST 2016

*****************************************************************************

Alias Name: sdtest1103
Type: CertificateEntry
Subject: C=US,ST=New Jersey,L=sdtest1103,O=sdtest1103,CN=sdtest1103
Issuer: C=US,ST=New Jersey,L=sdtest1103,O=sdtest1103,CN=sdtest1103
Serial Number: 3FD7sdE75B34EAE89E
Valid from: Tue Sep 24 14:29:37 EDT 2013 until: Mon Sep 19 14:29:37 EDT 2013

*****************************************************************************

Alias Name: sdtest1104
Type: CertificateEntry
Subject: C=US,ST=sdtest1104,L=sdtest1104,O=sdtest1104,CN=sdtest1104
Issuer: C=US,ST=sdtest1104,L=sdtest1104,O=sdtest1104,CN=sdtest1104
Serial Number: 3FDTgH34EAE89w
Valid from: Tue Sep 24 14:29:37 EDT 2013 until: Mon Sep 19 14:29:37 EDT 2010

*****************************************************************************

Alias Name: sdtest1105
Type: CertificateEntry
Subject: C=US,ST=sdtest1105,L=sdtest1105,O=sdtest1105,CN=sdtest1105
Issuer: C=US,ST=sdtest1105,L=sdtest1105,O=sdtest1105,CN=sdtest1105
Serial Number: 3FDTgH34EAE89w
Valid from: Tue Sep 24 14:29:37 EDT 2013 until: Mon Sep 19 14:29:37 EDT 2018

*****************************************************************************

END OF INPUT FILE

OUTPUT FILE

sdtest1103
sdtest1104

Thank You

Huby

2
Contributors
1
Reply
18
Views
2 Years
Discussion Span
Last Post by griswolf
0

For a (ba)sh script I'd look at (g)awk, which allows you to write little functions based on a regex match. You can set (global) variables within the functions, and you can check their values which gives you something resembling a state machine.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.