Pages

Monday, March 3, 2008

Finding large files and directories in linux

# Finding large files and directories in linux
# Finding files above 100 Mb
find /opt/ldap type f -size +10000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
# Finding directories above 100Mb
find / -type d -size +100000k
# Sort directories as per size with du

du --max-depth=1 -m | sort -n -r
# Finding Directory sizes
du -sh folder_name
du -ch folder_name
du -csh folder_name
# Truncating in use files
cat /dev/null > file_name
# Deleting contents of large directories
# Ref: http://www.killersites.com/mvnforum/mvnforum/viewthread?thread=3236
# If you want to delete all file starting with the name test in the current directory, then run this command
find . -name 'test*' | xargs rm