我想使用“ sed” +“ find” 我的sed命令效果很好,但它返回find错误
伟大的sed命令:-)
文件
&& chmod 0750 /tmp/htdocs/bin/cachetool.phar \
&& chown -R 82:82 /tmp/htdocs
伟大的sed命令:-)
sed -r 'N;s/\\([^\\]*\n\s*&& chown -R 82:82)/\1/;P;D' file
结果确定:
&& chmod 0750 /tmp/htdocs/bin/cachetool.phar
&& chown -R 82:82 /tmp/htdocs
不良sed +查找命令...
find /tmp/ -name myfile -exec sed -i 'N;s/\\([^\\]*\n\s*&& chown -R 82:82)/\1/;P;D' {} \;
错误
sed: -e expression #1, char 11: unterminated `s' command
答案 0 :(得分:1)
一个简单的解决方案是将sed命令放在文件中,然后使用该文件调用sed。
find /tmp/ -name myfile -exec sed -r -f sedfile {} \;
sedfile
所在的位置
N;s/\\([^\\]*\n\s*&& chown -R 82:82)/\1/;P;D