What do I need to do if I want to list all the files (not directories) and their size, with their sizes sorted from largest to smallest? I tried find . -type f -exec ls -Shl {} \; but it does list the files in order (of their size). Anyone can help??
            Asked
            
        
        
            Active
            
        
            Viewed 1.1k times
        
    2
            
            
         
    
    
        Suky Zhang
        
- 25
- 1
- 1
- 3
- 
                    https://unix.stackexchange.com/questions/53737/how-to-list-all-files-ordered-by-size – mechanical_meat Feb 13 '20 at 21:15
- 
                    2Try `find . -type f -printf '%k %P | sort -g` – jordanm Feb 13 '20 at 21:41
1 Answers
7
            Use + instead of \;.
find . -type f -exec ls -Shl {} +
\; calls ls once per file whereas + calls it a single time with all the matched file names.
 
    
    
        John Kugelman
        
- 349,597
- 67
- 533
- 578
- 
                    1The `+` does not process all files, well that depends on how much files is there to process. With the `+` find will process as much files as possible while avoiding `argmax` see https://www.in-ulm.de/~mascheck/various/argmax/ You know the error that says `list arguments too long` see https://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands – Jetchisel Feb 13 '20 at 21:35