Reputation: 343
This is what I normally use to add numbers to the beginning of each line:
awk '{ print FNR " " $0 }' file
However, what I need to do is start the number at 1000001
. Is there a way to start with a specific number like this instead of having to use line numbers?
Upvotes: 2
Views: 108
Reputation: 203635
$ seq 5 | awk -v n=1000000 '{print ++n, $0}'
1000001 1
1000002 2
1000003 3
1000004 4
1000005 5
$ seq 5 | awk -v n=30 '{print ++n, $0}'
31 1
32 2
33 3
34 4
35 5
Upvotes: 1
Reputation: 785196
You can just add 1000001
to FNR
(or NR
):
awk '{ print (1000001 + FNR), $0 }' file
Upvotes: 1