Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ubuntu 如何使用sed替换子文件夹中的文本_Ubuntu_Sed - Fatal编程技术网

Ubuntu 如何使用sed替换子文件夹中的文本

Ubuntu 如何使用sed替换子文件夹中的文本,ubuntu,sed,Ubuntu,Sed,我使用以下代码替换HTML文件中的一些文本: sed -i 's/tttt/new-word/g' /home/zjm1126/*.html 不过,这不会搜索子文件夹中的文件。如何将此命令应用于子文件夹?您可以尝试以下操作吗 find /home/zjm1126/ -name '*.html' -print0 | xargs -0 sed -i 's/tttt/new-word/g' for z in `find /home/zjm1126/ -type f -name "*.html"`;

我使用以下代码替换HTML文件中的一些文本:

sed -i 's/tttt/new-word/g' /home/zjm1126/*.html

不过,这不会搜索子文件夹中的文件。如何将此命令应用于子文件夹?

您可以尝试以下操作吗

find /home/zjm1126/ -name '*.html' -print0 | xargs -0 sed -i 's/tttt/new-word/g'
for z in `find /home/zjm1126/ -type f -name "*.html"`; do
sed -e 's/tttt/new-word/g' $z>temp;
done