Hi guys,
I desperately need some help here...
I need to parse a file similar to this:
I need to read the values for MY_BANNER_SSHD and WARNING_MESSAGE. The value could be empty/single line or multi-line!
# Comments
.
.
.
Some lines
MY_BANNER_SSHD=""
WARNING_MESSAGE=""
# Comments
.
.
.
Some lines
I have tried-
cat MYHardening.cfg | sed -n '/^MY_BANNER_SSHD=/,/"/p' | sed 's/MY_BANNER_SSHD=//g' | grep -v ^WAR| tr -d \" > tempfile1
cat MYHardening.cfg | sed -n '/^WARNING_MESSAGE=/,/"/p' | sed 's/WARNING_MESSAGE=//g' | tr -d \" > tempfile2
If there are multi-line values in those variables this seems to work fine!
But, when they are null, in tempfile2 I get the trailing part of the file starting after WARNING_MESSAGE=""
Can someone help please...
If you could put the message without newline ( let it be exceeds the line width ) it should work.
Is is acceptable for you?
something like..
# Comments
.
.
.
Some lines
MY_BANNER_SSHD=""
WARNING_MESSAGE="some text"
WARNING_MESSAGE="some text which is too long too fit in single linesome text which is too long too fit in single line some text which is too long too fit in single line some text which is too long too fit in single line"
# Comments
Please let us know if you want to stick with your current format.