|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
Softpanorama Search
|
Among categories of files with specific sizes the most popular are probably zero-length file and "huge files".
Zero length files formally might be considered a subclass of abnormal files but in reality they are often used in software installations. Do not try to delete them unless you understand what you are doing.
Here is some examples:
find / -type f -size 0 -lsYou can also use special predicate -empty
$ find . -empty -exec ls {} \;
After finding empty files, you might choose to delete them by replacing thelscommand with thermcommand. But it's better to verify the list before jumping the gun...
find / -type f -size +100M -ls
find / -type f -size +12K -size -15K -mtime -3 -ls
find /data -type f -size +100M -printf "%s:%p\n" | sort -nr | head -10
or, disregarding the minimum threshold of 100M just
find /data type f -printf "%s:%p\n" | sort -k1rn | head -10
Notes:
- We assume that you are using GNU find
- To print the top 10 largest "files and directories" you can use du -a . | sort -nr | head
- For more examples you can also look at
As with abnormal files discussed in previous section it is important to exclude certain parts of the directory tree from searching. You can use all approaches discussed in section 6 but often more practical and more simple to use a small Perl script to weed "junk" directories. For example:
#!/usr/bin/perl open(SYSLOG,"find / -type f -size 0 -ls|"); @pattern=( "/var/spool/", "/var/tmp/", "/var/locks/", "/var/ct/", "/var/ifor/", "/usr/lpp/", "/usr/omni/log/debug.log", "/tmp/", "/proc/", "/.swdis/", "/etc/Tivoli/tec/", "/usr/omni/lib/perl", "/opt/TMF/db/nti2171.db/", "/opt/tivoli/EPProxy/", "/opt/tivoli/TWS/stdlist/", "/var/adm/logs/", "/oracle/app/oracle/product/9.2.0/", "/oracle/app/oracle/product/9.2.0_OLD/", "/usr/opt/perl5/lib/5.8.2/aix-thread-multi/", "/usr/opt/perl5/lib64/5.8.2/aix-thread-multi-64all/", "/usr/opt/perl5/lib/site_perl/5.8.2/", "/usr/lib/objrepos/", "/usr/aix/_AIX_print_subsystem", "/etc/ipsec/inet/DB/", "/etc/objrepos/" ); while() { $data=$_; $line=substr($data,65); chomp($line); $found=0; foreach $string (@pattern) { if ( index($line,"$string") > -1 ) { $found=1; last; } } if ($found == 0 ) {print "$data\n";} }
Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Disclaimer:
Created: May 16, 1997; Last modified: August 25, 2009