Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找执行sed附加到一系列文件的特定部分的操作,例如:
sed
sed -i "s/test:\n/&$(<test.file)/g" foo.txt
有没有一种方法可以输出文件或一些 BASH 变量并将其放入 sed 以输入文件。
sed '/^test:$/{r test.file d}' foo.txt
应该做的伎俩。请注意,文件名后的文字换行符在所有版本的 sed 中都不是必需的,但建议使用。r 命令读取指定文件的内容。