How to sort by file size with ls?
Linuxmisc » Unix shell
Could anyone kindly tell me how to let "ls -l" output the file details
sorted by file size? Or any shell tools or scripts are also welcome.
Thanks.
Wonder
If you have the GNU vesion of ls, use the -S option.
Otherwise, pipe it through sort:
ls -l | sort -n +4
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2003, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
ls -l |sort -k5rn,5
Regards,
Ed
ls -l | sort -r -n -k 5
Arvid
With zsh:
ls -fld *(OL)
--
Stphane
ls -l | sort -k 5n
or better still, if u have gnu ls:
ls -Slr
will list files in increasing order of size.