嗨,我遇到了一些问题。
我有一个原始文件:
$cat original.txt
User has access to the system
第二个文件包含我要添加到原始文件的内容:
$cat toAdd.txt
Anna
结果应如下:
$cat original.txt
User Anna has access to the system
我尝试了几个选项,例如:
sed '/has/e cat toAdd.txt' original.txt
但它不起作用: - (
请帮助!!
答案 0 :(得分:1)
通过awk,
$ awk 'FNR==NR{var=$0; next}{for (i=1;i<=NF;i++){if($i=="has"){$i=var" "$i}}}1' toAdd.txt original.txt
User Anna has access to the system