Sed不使用find命令

Sed不使用find命令,sed,Sed,我正在尝试对目录中的所有文件运行此sed脚本: sed.s: /<constants>/a\ <const type="profElem" name="mission_description" value="NCEP and NCAR Reanalysis Monthly Means and Other Derived Variables"/> 我得到一个错误: sed: -i may not be used with stdin 如何使其工作?您的sed版本似乎要求

我正在尝试对目录中的所有文件运行此sed脚本:

sed.s:

/<constants>/a\
<const type="profElem" name="mission_description" value="NCEP and NCAR Reanalysis Monthly Means and Other Derived Variables"/>
我得到一个错误:

sed: -i may not be used with stdin

如何使其工作?

您的
sed
版本似乎要求您将备份扩展传递到
-I
选项。如果您对自己的命令非常自信,可以尝试将其扩展为零长度,如下所示:

find . -exec sed -f sed.s -i '' {} \; 

我想看看文件列表。你能发布
find的结果吗-exec echo{}\
find . -exec sed -f sed.s -i '' {} \;