Reputation: 59
I'm attempting to automate the following process:
The lines containing sequential numbers (0001, 0002, etc.) would contain just the number so I'm assuming adding a carriage return would be needed.
Is it also possible when numbering lines to include a space before numbers 1-9 so they line up with 10-25?
So something like...
0001
1 This is text
2 Some more text
↓
9 Text here
10 Text here
↓
24 Additional text
25 And some more text
0002
1 Text again
2 More text
↓
9 Text here
10 Text here
↓
24 Additional text
25 And some more text
0003
Upvotes: 0
Views: 491
Reputation: 195179
interesting question, I got this line, which gives required formatted output:
awk '{s=(NR-1)%25}!s{printf "%04d\n", ++k}{printf "%2d %s\n",s+1,$0}' file
Upvotes: 1
Reputation: 45293
using awk
awk 'FNR%25==1{printf "%04d\n",++i;s=1}{print s++,$0}' file
Upvotes: 2