String replacement for all files in directory

Joel Goguen jtgoguen at gmail.com
Sat Nov 29 02:31:07 UTC 2008


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.

-- 
Joel Goguen
Bug-free code is a myth.
Registered Linux User #391952
Registered Ubuntu User #15951
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20081128/b40ce68e/attachment.sig>


More information about the ubuntu-users mailing list