Suky Zhang
Suky Zhang

Reputation: 25

how to combine ls and find command?

What do I need to do if I want to list all the files (not directories) and their size, with their sizes sorted from largest to smallest? I tried find . -type f -exec ls -Shl {} \; but it does list the files in order (of their size). Anyone can help??

Upvotes: 2

Views: 16436

Answers (1)

John Kugelman
John Kugelman

Reputation: 361595

Use + instead of \;.

find . -type f -exec ls -Shl {} +

\; calls ls once per file whereas + calls it a single time with all the matched file names.

Upvotes: 10

Related Questions