[NTLUG:Discuss] Quickest way to edit file?

Fred James fredjame at fredjame.cnc.net
Mon Jul 23 10:18:43 CDT 2007


Daniel Hauck wrote:

>>I have a text file with several hundred lines, each with a single
>>email address.  Occasionally I want to add or delete an address.
>>Adding is easy:
>>
>>   echo 'user at xyz.org' >> filename
>>
>>What's the easiest way to delete a single line in a file?  I've been
>>doing it easily enough using vi, but can I do it with a single
>>command?
>>
>>    
>>
>
>Woo!  I don't know, but I'm guessing someone here knows right off the
>top of his head (I'm betting Chris Cox comes up with the best answer)
>but this is of good general interest.  I'll be saving the answer to this
>problem for future use as you can bet it'll come in handy!
>
>_______________________________________________
>http://www.ntlug.org/mailman/listinfo/discuss
>
>  
>
For a single address ...
grep -v regex original_file > new_file
For multiple addresses ...
grep -vf file_of_regexes original_file > new_file
Hope this helps
Regards
Fred James


More information about the Discuss mailing list