in reply to help: extracting multiple lines from file based on match in one line
If the tagging for the data structure went like this, it would qualify as valid XML:
Not only would you have the option of using some very handy and powerful XML modules and tools on the data, but you would also find it easy to do "one-liner" stuff using the constant-string close tag as the input record separator -- e.g.:<rec id=4> varFoo = bar some text some text ... </rec>
As it is, with a space in every close tag, and all close tags being different, your data is not XML, and it's a pain in the neck.# command line perl script to put all "var2 = 3" chunks into a separat +e file: perl -ne 'BEGIN{ $/="</rec>\n" } print if /var2 = 3/' input > var2_3.o +utput # just do the opposite (change "if" to "unless") to save the other chu +nks elsewhere
|
|---|