I'm trying to find the 50 largest file in a directory named /sasdb and its' subdirectories. I'm using the find command and a pipe to awk
Not sure if I'm actually getting the largest files from this directory and its subdirectories. Here is the code I used...
find /sasdb -ls | awk '{print $0}' | sort -n >> my.lst
tail -50 my.lst >> largest_files.lst
Any suggestions would be greatly appreciated.
Thank You
find /home/test -printf "%s:%p\n"|sort -k1n|tail -50
I tried this and receiveed an error messge that stated bad option -printf
find /sasdb -printf "%s:%p\n"| sort -kin| tail -50
igidttam,
See if this works for you:
du -a | sort -nr | head -50
1 Like
you do not have GNU find.
you first approach should be fine, just that you should check $0 , i don't think its the size. but pls do check.
find /home/test -type f -ls | awk '{print $7}' | sort -n | tail -50
this will include size of directories. think OP just wants largest files?
yes this gives me the directories. I just need the file names.
thanks
find . -type f -exec du {} \; | sort -nr | head -50
this works for me.
I appreciate your help. ThankYou