View Single Post
  #5   (View Single Post)  
Old 22nd September 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

A more portable approach then relying on GNU SED / FreeBSD SED; might be to use perl, if you know the language.

Code:
$ perl -i -pe 's/foo/bar/g' file


NB that because -i renames or deletes the original file before creating a new file of the same name, UNIX-style soft and hard links will not be preserved.


see perlre, perlrequick, perlreref, perlretut manual pages; if necessary for more advanced pattern matching notes.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote