shell脚本加后缀的每一行 [英] shell script add suffix each line
本文介绍了shell脚本加后缀的每一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问:我需要在一个文本文件中的每一行的末尾加点的词语。有谁知道任何Linux的bash shell脚本,它可以做这个工作?谢谢!
例如:添加文字完成
在每行的末尾:
一号线ABCDEFG完成
2号线ABCDEFG DONE
3号线abcdeft完成
解决方案
使用awk的:
的awk'{$打印0做}'INFILE
或内联标志sed的:
SED -i.bak的/ $ /做/'INFILE
Question: I need to add some words at the end of each line of a text file. Does anyone know any Linux bash shell script that can do this job? Thanks!
Example: add word done
at the end of each line:
line1 abcdefg done
line2 abcdefg done
line3 abcdeft done
解决方案
Use awk:
awk '{print $0 " done"}' inFile
OR sed with inline flag:
sed -i.bak 's/$/ done/' inFile
这篇关于shell脚本加后缀的每一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文