One-line global string replace in all files with sed (or awk?)
markzero
mark at darklogik.org
Thu Jan 27 22:50:36 PST 2005
> find . -type f | xargs grep -l 'foo' | \
> xargs sed -i '' -e 's/foo/bar/g'
>
> When passed the -l option (this is a lowercase 'EL'), it will not print
> the matched lines. Only the name of the files that *do* match. Then,
> once you have a list of files that really do match with 'foo' as a
> pattern, you can xargs sed on the list to substitute whatever you want :-)
>
Egh, I forgot about -l. There's me piping things into the bit bucket.
*shuffles off into the shadows*
--
PGP: http://www.darklogik.org/pub/pgp/pgp.txt
B776 43DC 8A5D EAF9 2126 9A67 A7DA 390F DEFF 9DD1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 825 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20050128/0d10fc19/attachment.bin
More information about the freebsd-questions
mailing list