Linux-Noob Forums
largest file in a directory tree - Printable Version

+- Linux-Noob Forums (https://www.linux-noob.com/forums)
+-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html)
+--- Forum: Tips and Tricks (https://www.linux-noob.com/forums/forum-59.html)
+---- Forum: Filesystem Management (https://www.linux-noob.com/forums/forum-26.html)
+---- Thread: largest file in a directory tree (/thread-3737.html)



largest file in a directory tree - hijinks - 2004-01-15


So you did a df and noticed that /var was full or you just want to find what the biggest file in the directory tree is. Well run this command and it'll show you.

 



Code:
ls -lsR | sort -n




 

That will sort all of the files and place the largest files at the end.




largest file in a directory tree - gamekeeper - 2004-01-16

Neat :P



largest file in a directory tree - anyweb - 2004-01-27


also

 

du -ch --max-depth 2 /

 

try that




largest file in a directory tree - shigawire - 2004-07-12


find is your friend... ;)



Code:
#!/bin/bash
# home_hogs.sh - Find large files in /home - 4/99 SW
# SysAdmin logfile = scriptname+date-timestamp.log
# Finds files > 10000k starting from /home
# Modify size accordingly (-size +100000) =/~10mb depending on blocksize
# Outputs filename="hogs19990401.log" to ./ (current dir)

# Set up your variables  -no spaces before/after = in bash
# Legacy systems /bin/sh use backticks nstead of $() for command substitution
#HOGS="hogs`date +%Y%m%d`"; export HOGS
# also find may not support the -size +[n]k flag

#set -t

EMAIL=sysadmin@mydomain.com
DATE2=$(date +%Y%m%d)
HOGS="hogs${DATE2}.log"

# Execute find command & log disk hogs
# 100mb
find /home -type f -size +100000k -print | xargs ls -l | tee $HOGS
# 10mb
#find /home -type f -size +10000k -print | xargs ls -l | tee $HOGS
# 1mb
#find /home -type f -size +1000k -print | xargs ls -l | tee $HOGS
elm -s "Disk Hogs" ${EMAIL} < ${HOGS}




hijinks tip could be substituted for the "xargs ls -l" portion to improve the listing & sort. -HTH