I have a large data file containing over a thousand entries. I would like to sort them but maintain the original line numbers. For instance,
1:100
2:120
3:10
4:59
Where the first number is the line number, not saved in the data file, separated by a colon from the real number. I would like to sort it and keep the line numbers bound to their original lines, with an output of:
2:120
1:100
4:59
3:10
If possible, I would like to do this without creating another file, and numbering them by hand is not an option for the data size I'm using.
Given a file
test.dat
:... the command:
... gives the output that you seem to be looking for (though with the fields delimited by tabs, which is easily changed if necessary):