[olug] Unix Tip: LISTING FILES BY SIZE

Mike Hostetler thehaas at binary.net
Fri Mar 14 19:34:03 UTC 2003


On Fri, Mar 14, 2003 at 11:25:43AM -0800, Unix Guru Universe wrote:
> LISTING FILES BY SIZE
> 
> 
> If you want to have a listing of the 
> files sorted by size, you can use the 
> following command(s), it will list 
> the files in decrease order. if you 
> need to do the same thing recursively,
> you could use the second one.
> 
> ls -l | grep ^- | sort -nr -k 5 | more
> 
> ls -lR | grep ^- | sort -nr -k 5 | more
> 

On Linux (and others using GNU's ls) it's even easier:
	ls --sort=size -l |more

To sort by how old the files are, you do this:
	ls --sort=time -l |more

(most recent files are first)

You can change the time to "mtime" or "atime" with "--time=atime", etc.

Yes, I have spent some time reading the manual page for ls . . . 

-- mikeh



More information about the OLUG mailing list