bergman on 31 Aug 2010 09:38:07 -0700 |
The pithy ruminations from linc <linc@lincgeek.org> on "Re: [PLUG] Sed or awk help?!" were: => Walt Mankowski wrote: => > On Tue, Aug 31, 2010 at 12:11:50PM -0400, linc wrote: => >> Walt Mankowski wrote: => >>> On Tue, Aug 31, 2010 at 12:03:49PM -0400, linc wrote: => >>>> DOH! Yeah, you are right. Have to use something like: => >>>> => >>>> sed 's/.CEL//' filename > newfile => >>>> instead... => >>> That's still not quite right. You should escape the period and anchor => >>> the end of the string. This is better: => >>> => >>> sed 's/\.CEL$//' filename >newfile => >> Seems to work fine without that?? => > => > Try it on => > => > fooCELbar.CEL => > => > I mean, there's a good change that all the instances of CEL occur at => > the ends of the filenames, but why take a chance? => > => > Walt => > => => HEH! How about THIS one...: => => sed 's/\.CEL//g' filename > newfile => Now I know why I hate sed :) A bit better, but still wrong. Please try the commands on sample data. You aren't restricting the replacement to the end of the line. Try it on this data and see the results. original data file: foo.CEL.orig processed data file: foo.CEL.proc new file name: foo.BAR.CEL send invoice to client at: JOHN.DOE@VERIZON.CELLULAR.COM rm -rf /etc.CEL/* In this example, only line 3 should be changed. Changing line 4 is a problem. Changing line 5 is a really big problem. Mark ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|