Can I sort the output?

QuestionsQuestions8 SkillsProBasic Files OperationsAug, 31 2025
0111

Yes, you can sort the output using the sort command in combination with other commands. For example, if you want to sort the output of the du command by size, you can use:

du -h | sort -h

This will sort the output from smallest to largest. If you want to sort it in reverse order (largest to smallest), you can add the -r option:

du -h | sort -hr

Additionally, if you want to focus only on the immediate subdirectories and sort them, you can use:

du -h --max-depth=1 | sort -hr

This will show and sort only the immediate subdirectories of the current directory.

0 Comments

no data
Be the first to share your comment!