文件添加行号

# 在每一行的行首,添加宽度为3的行号,并与行内容以“,”隔开
awk '$0=sprintf("%3s", NR)","$0' filename
原文地址:https://www.cnblogs.com/delta1037/p/13433221.html