On Wed, Dec 8, 2010 at 11:46 PM, Mike Walter <[email protected]> wrote:
> I'd been looking for a clean idiom for sorting a complete file from XEDIT
> using Pipeline's much more powerful sort arguments. I also did not want
> to write to disk during that process.
>
> Most of the examples I'd run across were somewhat awkward. So I wrote the
> following and wonder if more-expert plumbers that I would take a look at
> it and comment where it might be simplified. I realize that there are all
> sort of bells and whistles that can be added to such a sort function, but
> that's a separate discussion from a clean, rather concise example.
I believe you can do it a bit simpler (uh, shorter) with
| sort ..
| strliteral cond /:0 DELETE */
| x: if take | subcom xedit | xedit | x:
That also takes away the stuff around your 'elastic' and saves me from
making offensive comments about that :-) You might also reconsider
the use of 'hole' after a stage like subcom (only eof on the secondary
output will make it prematurely terminate)
So you get the file in memory twice (once in XEDIT and once in the
sort stage). I suppose that when it does not fit we don't get to
output the DEL * command...
If the file were already fairly sorted, would it make sense to
generate the XEDIT commands to move the lines to their proper location
rather than replace it?
Sir Rob the Plumber