Suky Zhang
Suky Zhang

Reputation: 35

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: 3

Views: 16705

Answers (1)

John Kugelman
John Kugelman

Reputation: 362187

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: 11

Related Questions