Find Command – List Files Larger Than {size} Sorted by Date

findls

I want to solve the problem 'list the top 10 most recent files in the current directory over 20MB'.

With ls I can do:

ls -Shal |head

to get top 10 largest files, and:

ls -halt |head

to get top 10 most recent files

With find I can do:

find . -size +20M

To list all files over 20MB in the current directory (and subdirectories, which I don't want).

Is there any way to list the top ten most recent files over a certain size, preferably using ls?

Best Answer

The 'current directory' option for find is -maxdepth 1. The whole commandline for your needs is:

find . -maxdepth 1 -type f -size +20M -print0 | xargs -0 ls -Shal | head

or

find . -maxdepth 1 -type f -size +20M -print0 | xargs -0 ls -halt | head
Related Question