如何在文件中的每一行的开头添加数字?
@H_301_1@例如。:
This is the text from the file.@H_301_1@成为:
000000001 This is 000000002 the text 000000003 from the file.
AWK的printf,NR和$ 0使得对格式化的精确和灵活控制变得容易:
原文链接:https://www.f2er.com/bash/388977.html~ $ awk '{printf("%010d %s\n",NR,$0)}' example.txt 0000000001 This is 0000000002 the text 0000000003 from the file.