[NTLUG:Discuss] Quickest way to edit file?

Fred James fredjame at fredjame.cnc.net
Mon Jul 23 11:16:36 CDT 2007


Lance Simmons wrote:

>On 7/23/07, Fred James <fredjame at fredjame.cnc.net> wrote:
>
>  
>
>>For a single address ...
>>grep -v regex original_file > new_file
>>    
>>
>
>I've done something similar with sed a few times, but it still leaves
>the extra step of renaming new_file back to original_file.
>
>For some reason, that extra step is the problem for me -- apparently
>it is too taxing for my feeble brain, because it slows me down every
>time.  Did I come up with a unique name for new_file?  Did I mess up
>when I renamed new_file back to original_file?  Am I sure I don't now
>have _three_ files instead of one?  That I didn't just delete
>everything by accident? Better check on that... and so on. By the time
>I get finished, I could have done the job with vi many times over:
>
>   vi file /suitable-pattern-fragment  dd :wq
>
>So maybe vi is the fastest way for someone as easily confused as me.
>
>  
>
Lance Simmons
Your millage may vary, of course, but when I find an activity that I do 
regularly, I tend to put a little effort into a script - especially if 
it is the type of thing that I might have to do while sleep deprived, or 
extremely busy with other stuff.  For example, the script in this case 
might offer one the option of adding, deleting, or changing an address, 
and then employ the appropriate commands to accomplish the desired 
task.  Naturally (in my mind anyway), there should be functions for 
adding, deleting, sorting, and removing duplicates, as well as renaming 
the new file back to the old name.
Hope this helps
Regards
Fred James



More information about the Discuss mailing list