How to sort ls output?

QuestionsQuestions8 SkillsProBasic Files OperationsAug, 24 2025
0908

You can sort the output of the ls command using various options. Here are some common ways to sort the output:

  1. Sort by name (default):

    ls
  2. Sort by modification time (most recent first):

    ls -lt
  3. Sort by modification time (oldest first):

    ls -ltr
  4. Sort by file size (largest first):

    ls -lS
  5. Sort by file size (smallest first):

    ls -lSr
  6. Sort alphabetically (case insensitive):

    ls -la --ignore-case

You can combine these options as needed. For example, to list all files sorted by size in reverse order, you can use:

ls -lSr

0 Comments

no data
Be the first to share your comment!