LWN.net Logo

Evolution of shells in Linux (developerWorks)

Evolution of shells in Linux (developerWorks)

Posted Dec 8, 2011 15:20 UTC (Thu) by felixfix (subscriber, #242)
In reply to: Evolution of shells in Linux (developerWorks) by ccchips
Parent article: Evolution of shells in Linux (developerWorks)

Every once in a while I come across some program that spits out several lines per record, and wished there were some way to use it in a pipeline. What it needs is some way to group lines into single lines and break them apart again, and two new pipeline utilities come to mind. The collector would group input lines based on command line criteria, such as a count or a pattern, and print them as a single line formatted per more command line args. The splitter would split each input line into several lines based on similar command line args.

Then programs which print several lines per record could be used with pipelines. It wouldn't be perfect, but all it would take is the two utilities, which I am, alas, too lazy and/or uninspired to write. The problem comes up too seldom to take the time to write it, and I have always found simple work arounds.


(Log in to post comments)

Evolution of shells in Linux (developerWorks)

Posted Dec 9, 2011 0:32 UTC (Fri) by wahern (subscriber, #37304) [Link]

You mean cut(1), paste(1), and join(1)?

They can be rather awkward to use, but I believe do what you want.

Evolution of shells in Linux (developerWorks)

Posted Dec 9, 2011 5:03 UTC (Fri) by jthill (guest, #56558) [Link]

sed does exactly what you want. For instance, to accumulate aptitude show's output one package per line: sed -nr '/^Package:/!{H;$!d};x;s/\n/\x0/gp'

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds