linux - cat read sed while 结合使用这段代码什么意思
本文介绍了linux - cat read sed while 结合使用这段代码什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
cat 22.txt | while read line ;do sed -i '' '/'${line}'/s/$/& zhangsan/g' 11.txt;done
特别是' '/'${line}'/这个看不懂
解决方案
这条sed命令中的前两个单引号不应该存在,应该是sed -i '/'${line}'/s/$/& zhangsan/g' 11.txt
意思是说用shell变量${line}的值作为正则匹配11.txt的内容,匹配则在行的结尾添加 zhangsan
这篇关于linux - cat read sed while 结合使用这段代码什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文