sed从file.txt插入到多个文件

前端之家收集整理的这篇文章主要介绍了sed从file.txt插入到多个文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我是这个sed&找到命令
find /home/www/ -name footer.PHP -exec sed -i 's/<\/body>/testmoe\n<\/body>/'

我需要用file.txt中的数据替换testmoe所以它是gona,

find /home/www/ -name footer.PHP -exec sed -i 's/<\/body>/file.txt\n<\/body>/'

任何纠正我命令的建议

解决方法

为了改善@ Iain的回答,我认为你可以像这样只通过一次:
#!/bin/sh
sed -i '/<\/body/ {
    r /path/to/file
    a </body>
    d
}' $1

这将搜索< / body>,将文件插入缓冲区,追加< / body>到缓冲区,然后删除原来的< / body>,正如Iain正确指出的那样无法移动.

原文链接:https://www.f2er.com/linux/398944.html

猜你在找的Linux相关文章