在目录和子目录中查找并替换为 sed [英] Find and replace with sed in directory and sub directories
本文介绍了在目录和子目录中查找并替换为 sed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我运行此命令以在我的站点根目录下的所有文件中查找并替换所有出现的apple"为orange":
I run this command to find and replace all occurrences of 'apple' with 'orange' in all files in root of my site:
find ./ -exec sed -i 's/apple/orange/g' {} ;
但它不会通过子目录.
这个命令有什么问题?
下面是find ./
的一些输出:
./index.php
./header.php
./fpd
./fpd/font
./fpd/font/desktop.ini
./fpd/font/courier.php
./fpd/font/symbol.php
推荐答案
你的 find
应该看起来像这样以避免将目录名称发送到 sed
:
Your find
should look like that to avoid sending directory names to sed
:
find ./ -type f -exec sed -i -e 's/apple/orange/g' {} ;
这篇关于在目录和子目录中查找并替换为 sed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文