how can I add an incremental number in from of a list of strings?
example:
cat names.txt
alpha
beta
gamma
I need a loop, which inserts a number before the string.. like this
1. alpha
2. beta
3. gamma
could that be possible in bash?
how can I add an incremental number in from of a list of strings?
example:
cat names.txt
alpha
beta
gamma
I need a loop, which inserts a number before the string.. like this
1. alpha
2. beta
3. gamma
could that be possible in bash?
The command line util nl
(= number lines) is made exactly for this:
nl -w 1 -s '. ' names.txt
prints
1. alpha
2. beta
3. gamma