parsing text using sed/awk or similar???
Hi,
I have a text file (conf) like: Code:
Section AAA Thanks, Indy |
Each section of variables could be put into an array:-
Code:
#!/bin/bash Code:
#!/bin/bash |
I read it as wanting each SECTION in a variable.
Section = `sed -n '/AAA/,/EndSection/p' filename` I just realized that, unlike many regexes, the "range" construct in SED is not greedy--ie, it stops on the first instance of "EndSection" |
In perl (awk, too, but there are others in this forum who do better awk than do I), this is a one-liner:
Code:
perl -e '$/="\n\n"; @sections=<>; foreach $section (@sections){ print "\nSECTION = $section\n"; |
Code:
set -- $(awk -F"=" '/Section/{f=1;next}/EndSection/{f=0}f{print $2}' file) |
thanks lads,
Works beautifully Indy |
All times are GMT -5. The time now is 04:53 PM. |