[PLUG] [Q] shell scripting

Roderick A. Anderson raanders at acm.org
Thu Dec 2 02:08:52 UTC 2004


I have a situation where I need to grep -vif a file writing the results 
back into the orginal file.  I'd _really_ rather not create a temporary to 
do this and every trick I can think of doesn't work.

An example of the way I'm trying to avoid.

/bin/cat transport.lst | grep -vif no-imgate.lst > transport.map

With "relay_recipients.map" containing the final results.  I don't want to
create the "transport.lst" if at all possible.  Keep the hits on the disk 
to a minimum.

Tricks like these _don't_ work.

grep -vif no-imgate.lst < transport.map > transport.map
cat transport.map | sort | grep -vif no-imgate.lst  > transport.map
cat transport.map | sort | grep -vif no-imgate.lst | sort > transport.map

I realize as I write this I was hoping I'd get some MS/PC-DOS like 
behavior.

Grep has no option for "inplace editing".  In the back of my mind a
thought floats around that I saw something many years ago (real years not
Internet years :-) about how to do this.  I just can't nail it down.

Any ideas? 


Thanks,
Rod
-- 
    "Open Source Software - You usually get more than you pay for..."
     "Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL"





More information about the PLUG mailing list