Grep \ Shell Script \ Parsing
Hi i know there is some other threads about grep and parsing but i tryed most of the other ways describe on the other questions and didnt work for me, i would like to parse a openssl log to a .csv and by that make the usual ; to pars the columns .
output to parse : Signature Algorithm: sha1WithRSAEncryption Issuer: C=PT, L=Jersey, O=UFO - UFO Solutions, CN=UFO Software ROOT Primary CA/emailAddress=ufo@wtf.us Validity Not Before: Jan 24 11:10:13 2011 GMT Not After : Jan 21 11:10:13 2021 GMT Subject: C=US, L=Jersey, O=UFO - UFO Solutions,OU=CER, CN=UFO PSS Intermediate CA/emailAddress=ufo@wtf.us Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (2048 bit) I want to parse the data in front of "Signature Algorithm :" , the dates in "Not Before:" and "Not After", and the values in front of "C=", "L=" , "CN=", "O=" , "OU= ", "EmaiAddress=" . And finally the Public key algorithm : , and RSA public key value the " (2048 bit) " to the >> example.csv The desired output would be : sha1WithRSAEncryption, Jan 24 11:10:13 2011 GMT, Jan 21 11:10:13 2021 GMT, PT, Jersey, UFO, etc. thanks in advance. |
Search for a download - why reinvent the wheel?
For something as involved as you are asking, grep & bash is a bit cumbersome. There is awk, and sed which might thrash it out better for you. That said, if you do go at this, there is an option for you to use perl's regular expression stuff which is a bit tidier and more definite than posix, in my experience. man perlre is your friend |
I have this :
Quote:
|
drd*;
I think you mean the data AFTER the keywords---for example, when it finds "Signature Algorithm:", it would return: "sha1WithRSAEncryption" To be clear, please post the desired output I'm guessing that it would be: "sha1WithRSAEncryption, Jan 24 11:10:13 2011 GMT, Jan 21 11:10:13 2021 GMT, etc." |
That is exactly what i want pixellany :)
the desired output would be : "sha1WithRSAEncryption, Jan 24 11:10:13 2011 GMT, Jan 21 11:10:13 2021 GMT, PT, Jersey, UFO, etc." |
Here is a start (written as a script):
Code:
#!/bin/bash I am QUITE SURE there is an easier way to do this......;) |
All times are GMT -5. The time now is 06:29 PM. |