本文介绍了sed:无法读取:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行以下命令:

find . -name '*.html' -exec sed "s/foo/bar/g" {} \;

文件结构如下所示:

./two/three.html
./two/two.html
./two/one.html
./three/three.html
./three/two.html
./three/one.html
./one/three.html
./one/two.html
./one/one.html

但是,sed 返回说找不到文件,即使这两个命令单独运行正常(即我可以自己运行 find,我可以自己运行 sed).

However, sed comes back saying the files could not be found, even though these two commands work fine on their own (i.e. I can run a find by itself, and I can run sed by itself fine).

我和同行一起看了看,他也被难住了.我最终选择了不同的路线,但我仍然想知道这里到底出了什么问题.

I had a peer look at it with me, and he was stumped also. I ended up going a different route, but I'd still like to know what exactly is going wrong here.

推荐答案

感谢 glenn jackman 的建议:

Thanks to glenn jackman for the advice:

我需要在括号周围加上引号:

I needed to place quotes around the brackets as such:

-exec sed "s/foo/bar/g" '{}' \;

而不是我最初发布它的方式.

Rather than how I initially posted it.

这篇关于sed:无法读取:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 14:15
查看更多