Solved Sort command output by a numerical column

Solved issue

damix9

Member
Joined
Jun 5, 2024
Messages
51
Reaction score
12
Credits
440
I have a script https://www.linux.org/threads/linux-org-user-created-helpful-shell-scripts.41234/post-249595
It outputs multiple lines, each line has some space-separated values. How to sort the output by 6th value? Treat it as a real number.
Bash:
./kt.sh info | sort -n -k 6
sorts in some random order.
For the output format see line 100 of the script
Bash:
...
printf "%3.0lf%% of %11d %4.0lf kb/s %s %8s %4s %s \n" $((100*$prog/$dsize)) $dsize $(($speed/1000)) $(echo "scale=5 ; $ratio / ($seed_time / 24)" | bc -l | awk '{printf "%.5f\n", $0}') $sl $pri "$name"
...

UPD
Solution
 
Last edited:


I found a working one-liner
Bash:
./kt.sh info | LC_NUMERIC=C sort -n -k 6
 

Members online


Latest posts

Top