Transferred from: http://rubyer.me/blog/1613/
Finding and replacing in a single file is simple, just don't say it. The search and replace of strings in all files in the folder will be remembered, recently deployed dozens of Linux servers, the summary is recorded.
Find files that contain strings under a folder
Example: Find all files in the/usr/local directory that contain "Rubyer.me".
' rubyer.me ' /usr/local/*
Vim replaces all string methods in a single file
Example: Replace all old in the current file with new
:%s/old/New/g#% means that the substitution says there is a row, and g means replacing all occurrences in a row.
Replace a file with a string under a folder
Sed combined with grep
Example: To change the Zhangsan in all files below the directory/www to Lisi, do this:
" s/old/new/g " ' grep old-rl/www '
Label:
>> original articles, welcome reprint. Reproduced please specify: Reproduced from Ruby fans, thank you!
>> original link address: Linux find and replace all files in the directory in the string
Linux find and replace strings in all Files under directory (reprinted)