[PLUG] [Q] shell scripting

wamorita wamorita at hevanet.com
Thu Dec 2 06:42:17 UTC 2004


Rod,

Why not use perl to process your file?  You should be able to read you file
into an array in memory, do sort and "grep" type operations on it and write
it back out over the original file.

- Bill Morita

wamorita at hevanet.com
Home: (503) 697-6994
Cell: (503) 260-3876



-----Original Message-----
From: plug-bounces at lists.pdxlinux.org
[mailto:plug-bounces at lists.pdxlinux.org]On Behalf Of Roderick A.
Anderson
Sent: Wednesday, December 01, 2004 6:09 PM
To: plug at lists.pdxlinux.org
Subject: [PLUG] [Q] shell scripting


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"


_______________________________________________
PLUG mailing list
PLUG at lists.pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug





More information about the PLUG mailing list