I have a file of a list of vehicles.
I have sorted them in ABC order and numbered the lines. How can I import this sort back into the original file?
I want a list with the numbered field added to the original file. The original file is not in ABC order.
EX:
(original file)
Chevy
Acura
Ford
Honda
(what I have with the command: sort -d cars | awk '{print NR, $0 }'
)
1 Acura
2 Chevy
3 Ford
4 Honda
(desired result)
2 Chevy
1 Acura
3 Ford
4 Honda
The command I used to get this so far is
sort -d cars | awk '{print NR, $0 }'
I have sorted them in ABC order and numbered the lines. How can I import this sort back into the original file?
I want a list with the numbered field added to the original file. The original file is not in ABC order.
EX:
(original file)
Chevy
Acura
Ford
Honda
(what I have with the command: sort -d cars | awk '{print NR, $0 }'
)
1 Acura
2 Chevy
3 Ford
4 Honda
(desired result)
2 Chevy
1 Acura
3 Ford
4 Honda
The command I used to get this so far is
sort -d cars | awk '{print NR, $0 }'