sed:1:“…”&引用;:命令代码f无效

sed:1:“…”&引用;:命令代码f无效,sed,Sed,当我在终端上运行上面的命令时,我得到了这个错误 grep -l \'texttofind\' * | xargs sed -i 's/toreplace/replacewith/g' 我看过几个论坛,没有发现任何关于代码f的内容。 任何帮助/见解都将不胜感激我发现了问题所在。我需要在-I之后和's/./../'之前添加': sed: 1: "forkliftDailyChecklistW ...": invalid command code f 请显示您正在使用的确切sed命令(而不是tor

当我在终端上运行上面的命令时,我得到了这个错误

grep -l \'texttofind\' * | xargs sed -i 's/toreplace/replacewith/g'
我看过几个论坛,没有发现任何关于代码f的内容。
任何帮助/见解都将不胜感激

我发现了问题所在。我需要在
-I
之后和
's/./../'
之前添加
'

sed: 1: "forkliftDailyChecklistW ...": invalid command code f

请显示您正在使用的确切sed命令(而不是
toreplace
replacewith
)。疯狂猜测:在其中一个术语中是否有一个
/
?是的。假设
grep
的输出是正确的,您应该在
sed
的参数中检查
/
。如果是这种情况,请尝试使用语法
's\u toreplace\u replace with\u g'
。下面是命令:grep-l\'/usr/local/www/apache22/data/htconfig/dbconfigure.php\'*.\124; xargs sed-i's/\/usr\/local\/www\/apache22\/data/'''''.$$u服务器[''''''''''''''DOCUMENT\u ROOT''''''\'''.'''''.'''''''''''.''''''''''.'''''.''''!您可能正在Mac或BSD系统上运行。BSD
sed
命令采用
-i
选项,但需要备份后缀(但允许使用空后缀)。提供基本的平台信息通常会有所帮助。
grep -l \'texttofind\' * | xargs sed -i '' 's/toreplace/replacewith/g'