command to find and replace a word in files directory wide

WebHostPro

Well-Known Member
PartnerNOC
Jul 28, 2002
1,726
27
328
LA, Costa RIca
cPanel Access Level
Root Administrator
Twitter
PWSowner said:
cd to the directory you want, then

replace "flippy" "flipper" -- *

to replace every occurance

Great thanks, also do you know how to go into sub directories like this as well.

So /home/all/folders get checked for the word and replaced in each file.

Thanks,
 

anup123

Well-Known Member
Mar 29, 2004
889
1
168
This Planet
I often use following format.

grep -rl 'flippy' * | xargs perl -p -i -e 's/flippy/flipper/'


But with care:

check if you get the right files with:

grep -rl 'flippy' * (say while you are within /home )

If yes, then run the full cmd

Anup