bash - pipe one long line as multiple lines -
say have bunch of xml files contain no newlines, contain long list of records, delimited </record><record>
if delimiter </record>\n<record>
able cat *.xml | grep xyz | wc -l
count instances of records of interest, because cat emit records 1 per line.
is there way write something *.xml | grep xyz | wc -l
something
can stream out records 1 per line? tried using awk
couldn't find way avoid streaming whole file memory.
hopefully question clear enough :)
this little ugly, works:
sed 's|</record>|</record>\ |g' *.xml | grep xyz | wc -l
(yes, know make little bit shorter, @ cost of clarity.)
Comments
Post a Comment