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