Searches for files containing the string in the current directory and subdirectories. grep -rn "searchme" ./ Replace all occurrences of searchme in the current file with replaceme. sed -i 's#searchme#replaceme#g' *.txt sed -i 's/searchme/replaceme/g' *.txt Replace all occurrences of searchme in subfiles in subdirectories with replaceme. sed -i 's#searchme#replaceme#g' ./*/*/*.txt sed -i 's/searchme/replaceme/g' ./*/*/*.txt Replace all occurrences of searchUrl in subfiles in subdirectories with replaceUrl. sed -i 's#http://www.searchme.com/#http://replaceme.com/#g' ./*/*/*.html Replace all occurrences of searchUrl in this file with replaceUrl. sed -i 's#http://www.searchme.com/#http://replaceme.com/#g' *.html Finally, check that all swaps are done. grep -rn "searchme" ./ 文章导航 Linux递归搜索字符串,批量替换,支持URL替换。 JAVA代码实现的一个简单的F5负载均衡功能