The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-13-2008
laiko laiko is offline
Registered User
 

Join Date: Apr 2008
Posts: 5
deleting a line but keeping the same file

Hi,

I want to delete a line in a file that contains a string. I tried:
grep -v "mystring" Myfile > Myfile

But this makes the Myfile empty. I read that I need to do something like:
grep -v "mystring" Myfile > Myfile.new
rm Myfile
mv Myfile.new Myfile


Is there a way to avoid creating a temporary file??

Thanks in advance.
Reply With Quote
Forum Sponsor