I would like to reorder a whole file by ascending time order.
file.txt looks like this:
a 12.24 text
a 1.45 text
b 5.12 text
i would like it to look like this
a 1.45 text
b 5.12 text
a 12.24 text
Thanks in advance
I would like to reorder a whole file by ascending time order.
file.txt looks like this:
a 12.24 text
a 1.45 text
b 5.12 text
i would like it to look like this
a 1.45 text
b 5.12 text
a 12.24 text
Thanks in advance
Use the sort
linux programme, not awk
. Precisely:
sort -n -k 2 <filename>
The sort
command may fit your needs better than awk
.
# sort -gk 2 test.txt
a 1.45 text
b 5.12 text
a 12.24 text
-g compares them as numbers instead of strings. And -k 2 sorts on the second column.