Sort ls-l owners on Unix

I want to sort the owners alphabetically from calling ls -l and cannot figure out how to do this. I know something like ls-l | sort will sort the file name, but how do I sort the owners in order?

+5
source share
4 answers

The owner is the third field, so use -k 3:

ls -l | sort -k 3

You can extend this idea to sort based on other fields, and you can have several options -k. For example, perhaps you want to sort by owner, and then size in descending order:

ls -l | sort -k 3,3 -k 5rn
+10
source

, , . . , ls tr, , , . *

, :

ls -l | tr -s ' ' | cut -d ' ' -f 3 | sort | uniq

* , .

+1

...

ls -l | cut -d ' ' -f 3 | sort | uniq
0

:

ls -l | awk '{print $3, $4, $8}' | sort

, . ( )

ls -l | awk '{print $3, $4, $0}' | sort

, ls -l, , , , ls -l

0

All Articles