将数据附加到unix中每行的末尾

时间:2013-07-12 18:08:27

标签: unix

我使用了问题中提到的选项:what-unix-command-can-we-use-to-append-some-text-to-a-specific-line-in-a-file

perl -p -e's{\n}{, extra information\n} if $. ==3' myfile
awk '{s=$0; if( NR==3 ){ s=s ", Extra Information" } print s;}' myfile > newfile
sed -e '3s/$/, Extra Information/' -i myfile

所有这些选项都附加数据,但是这些附加数据将进入下一行,即如果在检查文件时在第3行末尾附加数据,则附加数据将从第4行开始显示。

请您帮我把第3行末尾附加的数据作为单独的第4行。

0 个答案:

没有答案
相关问题