Jump to content

largest file in a directory tree

Recommended Posts

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.


ls -lsR | sort -n


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

Share this post

Link to post
Share on other sites



du -ch --max-depth 2 /


try that

Share this post

Link to post
Share on other sites

find is your friend... ;)

# 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

DATE2=$(date +%Y%m%d)

# 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

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...