Listing files sorted by size

This is a general linux question that I couldn’t figure out, sorry if it is the wrong place to ask.
I know that in terminal, “ls - R” will list subdirectory contents and “ls - S” will sort contents. I just want to get sorted by file sizes, regardless of main directory or subdirectory location. When I try “ls - RS”, I don’t get that result. Is there a way to sort all files (regardless of subdirectory location) by size and list them?

The equivalent method in Windows (sorry, I have no other analogy) would be to run a search for a specific file type (like .rar) and then sort results by size. That is what I’m trying except that I’m not picky about file type although I can declare it if need be.

Can you try
ls -la
ls -laS

1 Like

Both commands list subdirectories but refuse to list the contents. I figure it is something to do with “- R” but even your suggestions with R included lead to subdirectory contents only listed at the end and not interspersed with main directory or other subdirectories.

As far as I understand it, it should be -r and I even looked it up and the references said the same. -shrug-
I think we are missing something here. Will look up more later…

This is what I found for R vs r:

But I found the solution:
I used maxdepth 2 (I only have one level for each subfolder) and it works.

Thanks for the help.

1 Like