Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
largest file in a directory tree
#1

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.

Reply
#2
Neat :P
Reply
#3

also

 

du -ch --max-depth 2 /

 

try that

Reply
#4

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

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)