[Cialug] Algorithm; Cutting Up A File

Chris Freeman cwfreeman at gmail.com
Wed Dec 13 10:35:35 CST 2006


I would actually use awk for this. It should look like:

awk '/^<description>/,/^<\/description>/p' | awk '!/^<\/{0,1}description>/p'

There's probably a way to combine the two commands, but this does it just
fine.

In shell you could do:

for i in description procedure reference
do
    awk "/^<$i>/,/^<\/$i>/p" | awk "!/^<\/{0,1}$i>/" > datafile-$i.txt
done


Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20061213/e31f9ef4/attachment.html


More information about the Cialug mailing list