Sort output by column

command linesorttext processing

I'd like to take this command find -maxdepth 1 -type d | while read -r dir; do printf "%s:\t" "$dir"; find "$dir" | wc -l; done ( from here ). which has an output of basically

./kennel:       11062
./shadow:       15449
./ccc:  9765
./journeyo:     14200
./norths:       10710

and sort it by the numbers largest to smallest. but I'm not sure how to make sort, or whatever operate on a different column.

Best Answer

Pipe the lines through sort -n -r -k2. Edited to sort from largest to smallest.

Related Question