[TAG] 2c tip: filtering in-place

Jay R. Ashworth jra at baylink.com
Fri Mar 19 21:44:22 MSK 2004


On Fri, Mar 19, 2004 at 10:39:34AM -0500, Ben Okopnik wrote:
> On Fri, Mar 19, 2004 at 02:33:21PM +0530, Kapil Hari Paranjape wrote:
> > I have always thought that filtering files "in-place" was
> > not possible from the command line...
> > ...until today---one lives and learns.
> > 
> >   dd if=file bs=4k | filter | dd of=file bs=4k conv=notrunc
> > 
> > Where "file" is the file you want to filter and "filter" 
> > is the filtering program you want to apply.
> 
> The "buffer" program does exactly the same as the above; the process is
> called "reblocking".
> 
> buffer < foo | filter > foo

<interrupts self while raising hand to complain>

Oh, cause buffer reads the entire file before the '>' can stomp it?

Well, that's not *exactly* the same... :-)

Doesn't that still depend on order of evaluation by the shell?  Is that
defined?

Cheers,
-- jra
-- 
Jay R. Ashworth                                                jra at baylink.com
Member of the Technical Staff     Baylink                             RFC 2100
The Suncoast Freenet         The Things I Think
Tampa Bay, Florida        http://baylink.pitas.com             +1 727 647 1274

        "They had engineers in my day, too."  -- Perry Vance Nelson




More information about the TAG mailing list