String replacement for all files in directory

Kipton Moravec kip at kdream.com
Sat Nov 29 15:05:28 UTC 2008


Thanks. Now I know I have to read up on SED.

On Fri, 2008-11-28 at 22:31 -0400, Joel Goguen wrote:
> On Fri, 2008-11-28 at 20:16 -0600, Kipton Moravec wrote:
> > How do I do a simple string replacement of one string with another
> > string in all files in a directory?
> > 
> > For example:
> > 
> > I have 1200 files in a directory. Wherever I see the string
> > "footprint=0603C" in any of the files (may occur 0 or multiple times) I
> > want to replace with "footprint=CAPC0603N"
> > 
> > I do not know how to figure out what command to use so I can look it up.
> > 
> > Kip  
> > -- 
> > Kipton Moravec AE5IB
> > "Always do right; this will gratify some people and astonish the rest."
> > --Mark Twain
> > 
> > 
> > 
> Open a Terminal, go to the directory, and run this command:
> 
> sed -i 's/footprint=0603C/footprint=CAPC0603N/g' *
> 
> That will do the search/replace on all files.
> 
-- 
Kipton Moravec AE5IB
"Always do right; this will gratify some people and astonish the rest."
--Mark Twain






More information about the ubuntu-users mailing list