How to sort files by size?

QuestionsQuestions8 SkillsProBasic Files OperationsSep, 16 2025
0137

To sort files by size using the ls command, you can use the -S option. Here's how to do it:

Command:

ls -lS

Explanation:

  • -l: Lists files in long format, providing details like permissions, owner, size, and modification date.
  • -S: Sorts the files by size, with the largest files listed first.

Example:

If you want to see the sizes in a human-readable format, you can combine it with the -h option:

ls -lhS

This will display the files sorted by size, showing sizes in KB, MB, etc. If you have any more questions, feel free to ask!

0 Comments

no data
Be the first to share your comment!