![](/img/trans.png)
[英]How to add a number at the end of a certain line for multiple files in Linux?
[英]How to add the number of line at the end of line in linux
如何在linux中将相应行末尾的行数添加到文件文本中?
我知道这个命令,但是它在开头而不是结尾添加行数!
nl -ba -s ', ' fileName.txt > fileName2.txt
例如
5,10,33
7,17,77
不得不
5,10,33,1
7,17,77,2
在awk中:
awk '{print $0","NR;}' file
在我的系统上:
$ cat file
1 2
3 4
5 6
7 8
$ awk '{print $0","NR;}' file
1 2,1
3 4,2
5 6,3
7 8,4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.