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:
Capital S. This will sort files in size. Also see:
Update: To exclude directories: ls -lS | grep -v '^d' Update 2: 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. update 3: 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:
The |
|||||||||||
|
|
You could use something like find and sort.
(the 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
|
|||
|
|

