How to replace words in all files?
Sergey S. Ropchan
fenix at ramb.com.ua
Fri May 13 02:41:04 PDT 2005
find / -name '*' -print | xargs grep "lnc0"
- gives you all files in your system with lnc0 ...
perl -pi.bak -pe 's/lnc0/rl0/' file1 file2 ... fileN
- will replace lnc0 - rl0 in all specified files, with backuping of old
files in *.bak
> Hello!
>
> I have a bunch of configuration files which all contain the word,
> or the reference to, my dysfunctional network interface lnc0. I used
> to have this simple script -- to replace a word in all ASCII files
> containing it -- with another word. In this case, I need to replace
> the string `lnc0' with `rl0' in all my configuration files. And is
> it possible having this script tell me what files it modified?
>
> I promise I'll write it down this time :)
> And be generous on handing it back out to the society!
>
>
> --
>
> Fafa Hafiz Krantz
> Research Designer @ http://www.home.no/barbershop
> Enlightened @ http://www.home.no/barbershop/smart/sharon.pdf
>
>
>
More information about the freebsd-questions
mailing list