I've such a file:
name: xxx --- time: 5.4 seconds
name: yyy --- time: 3.2 seconds
name: zzz --- time: 6.4 seconds
...
Now I want to sort this file by these float numbers to generate a new file as below:
name: yyy --- time: 3.2 seconds
name: xxx --- time: 5.4 seconds
name: zzz --- time: 6.4 seconds
...
I've tried the command awk '{print $5}' myfile | sort -g
but this will show me ONLY the float numbers.
Best Answer
If using GNU
sort
or compatible, you can use its-g
switch to do a general numeric sort:The
-k5,5
tells sort to perform the sort on just the 5th column.Usage
Keep in mind the details from the
info sort
page: