我有file.txt一些内容.我想搜索一个字符串file1.txt,如果该字符串匹配,我想用该字符串的内容替换该字符串file.txt.我怎样才能做到这一点?
我尝试过使用sed:
sed -e 's/%d/cat file.txt/g' file1.txt
Run Code Online (Sandbox Code Playgroud)
这是在搜索匹配的字符串file1.txt并用字符串替换它cat file.txt,但我想要的内容file.txt.
在将文件插入到 sed 字符串之前,如何将文件的内容保存在变量中?
$content=`猫文件.txt`; sed "s/%d/${content}/g file1.txt"
| 归档时间: |
|
| 查看次数: |
19525 次 |
| 最近记录: |