How do I sort by file size? To list all files and sort them by size, use the -S option. By default, it displays output in descending order (biggest to smallest in size). You can output the file sizes in human-readable format by adding the -h option as shown. And to sort in reverse order, add the -r flag as follows.
What is the ls option to sort by file size Linux? To list or sort all the files by size, use the -S option, that tells the ls command to sort the file listing by size and the -h option makes the output a human-readable format.
How do I sort by file size in ls? To sort the output of the ls command by file size, use the -l -s option followed by the -h option, which sorts files by human-readable file sizes (e.g. KB or MB).
What is the ls option to sort by file size in Unix? The -S option is the key, telling the ls command to sort the file listing by size.