Sunday, April 17, 2005

ls sort files

The "ls" file/directory listing tool doesn't have built-in support for sorting files according to file size. But by piping the output to "sort", this can be done, e.g.

ls -al | sort +4n

Will sort by size from the smallest file to the largest. The following will display files from largest to smallest:

ls -al | sort +4nr
Post a Comment