|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Command to find largest file within multiple subdirectories
Hi!
I have a directory called uploadfiles, and underneath that is: user1 user2 user3 up to like user500 I'm trying to find the largest files in these /home/dwh/uploadfiles/user* directories. Is there a way to get let's say the top 10 biggest files? Thanks! |
|
#2
|
|||
|
|||
|
Code:
find . -printf '%s %p\n'|sort -nr|head will give you the "top-ten" ![]()
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
|
#3
|
|||
|
|||
|
Quote:
Thank you so much! If you don't mind I will repeat the code below with notes on what I understand and what I don't just so I can learn the meaning behind the code too! "find" searches for... "." within the current directory... "-printf" hmmm. -print would be to the screen? -printf to a file?? " '%s %p\n'" uh...u got me there... "|" pipe to... "sort" never used sort but I guess it sorts! ![]() "-nr" uh...hmm no idea... "|head" pipe to head, like heading a file similar to tailing a file? |
|
#4
|
|||
|
|||
|
if you donīt mind...
![]() "find" searches for... "." within the current directory... //-- no. "." is the current directory. find searches for any file in the current directory (and sub-dirs) "-printf" hmmm. -print would be to the screen? -printf to a file?? //-- printf is a common programming language function "print formatted" " '%s %p\n'" uh...u got me there... //-- this is the format strings. from the manual ("man find") you know that //-- %s is filesize in bytes, %p is filename with path, \n is a "new line" "|" pipe to... "sort" never used sort but I guess it sorts! "-nr" uh...hmm no idea... //-- from the manual ("man sort"): numeric sort, reverse sort "|head" pipe to head, like heading a file similar to tailing a file? //-- 100% correct. default is 10 lines. again, see "man head" //-- linux is , eh? |
|
#5
|
|||
|
|||
|
Very
!!It didn't even dawn on me to man the find command doh! Sorry ![]() Of course I can't really understand the man explanations half the time! I usually need to see a full example in use and the result of the command... |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > Linux Help > Command to find largest file within multiple subdirectories |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|