sean finney on 31 Aug 2010 09:42:39 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Sed or awk help?!

On Tue, Aug 31, 2010 at 12:23:44PM -0400, linc wrote:
> HEH!  How about THIS one...:
> sed 's/\.CEL//g' filename > newfile
> Now I know why I hate sed :)

you're still missing the EOL.  ex: "foo.celblah.cel".

since no-one has mentioned it yet: if you want to avoid duplicating the
file you could also use the in-place editing (assuming gnu sed here):

sed -i -e 's/\.CEL$//' filename

you can also put an "i" after the last slash if you want to fix this in a
case-insensitive manner.  and since TMTOWTDI, you can also do the same thing
via perl:

perl -p -i -e 's/\.CEL$//' filename

(yummy mneumonic: "pie!")

which is slightly more portable than sed since there exist many systems
whose default sed doesn't implement the "-i" extension but i think the
perl options have been around for quite a while.


Attachment: signature.asc
Description: Digital signature

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --