View Single Post
  #1   (View Single Post)  
Old 22nd September 2008
18Googol2's Avatar
18Googol2 18Googol2 is offline
Real Name: whoami
Spam Deminer
 
Join Date: Apr 2008
Location: pwd
Posts: 283
Default Command to find and replace, but not creating a new file

So I have a file, with a bunch of pattern "foo", and I wanna replace them with "bar":

Code:
blah1 foo1 blah2 blah3 foo2 blah4foo3
We all know all the pattern can be replaced by `sed` command, the catch is, you need to create a "temp" file to hold the output.

I wouldnt bother if the file size is just a couple of Kb, but, what if its a few hundred of Mb, Im restricted in disk space, then you are in trouble.

I think vim can do this with "-c" switch if iirc, but I believe there is a more elegant command out there...
__________________
The power of plain text? It can control an entire OS
Reply With Quote