I would like to list all files in the order of big to small in size and the files could be present anywhere in a certain folder.
Simply use something like:
This will sort files in size.
To exclude directories:
I see now how it still shows symbolic links, which could be folders. Symbolic links always start with a letter l, as in link.
Change the command to filter for a
On my system this only shows regular files.
To add recursion I would leave the sorting of the lines to the
If you do need the full path of the files, use something like this:
You could use something like find and sort.
If the file names may contain newline characters, with GNU find and GNU sort:
With zsh and GNU ls:
(note that older versions of zsh had issues with file sizes over 2^32).
Some operating systems have a limit on the size of the argument list passed to a command. In those cases, you'd need:
If you just want the list of files and not the detailed output, just do:
If you want to include hidden files (whose name starts with a dot, except
Saying that "the files could be present anywhere in a certain folder" implies that you want to recursively descend all directories (folders) within the starting directory (folder). This is what
This "finds" all files in the current working directory (
I wrote something to this extent a while back. You could pass an argument to specify how many files to list, or just type
Try these, it works fine for me.
Not perfect answer though but works to some extent
Adding to delh's answer and Stéphane Chazelas' comment...
The commands below will provide the desired output.
Human-readable, on GNU's sort / Linux:
In kilobyte units, on BSD / OSX / others:
For BSD / OSX, also see http://unix.stackexchange.com/a/188375/82895.