- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to find directory with many small files?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2001 11:59 AM
03-15-2001 11:59 AM
-Jim
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2001 12:17 PM
03-15-2001 12:17 PM
Re: How to find directory with many small files?
find / -size -100000000c -print
... this would find files smaller than 100000000bytes in size. You define how small a file you want to find
Or if your user keep their files in *.log you could search
find / -name *.log -print
... this finds based on *.log
You could output this to a file instead of -print with a redirect. Or if you know your users keep log files in their home directory (or where-ever) you could do what I sometimes do...find based on -name and -mtime.
find /home -size -10000000c -a -mtime +30 -exec rm {}
....this would find in the /home directory files smaller than that have not been accessed in 30+ days and remove them.
..BUT A WORD OF CAUTION...
Remember it is removing based on file size..so you need to becare you do not remove things that are needed. Your description of size and name is not real specific to find on... Also the size will find everything smaller than that figure but the exact same file size it would omit.
I might recommend running the find and outputing a file than review before you remove...
Just a thought,
/rcw
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2001 12:37 PM
03-15-2001 12:37 PM
Solution#!/bin/ksh
find . -type f -size -1000 -print | xargs dirname > /tmp/xxx.out
FILES=$(cat /tmp/xxx.out |sort -u)
for X in $FILES
do
echo $X $(cat /tmp/xxx.out | grep $X | wc -l )
done | sort -nr +1
rm xxx.out
What this does is find all files less than 1000 bytes (you can change the size if you want), takes the directory name where each files is located, and writes them to a file. Then it goes through the file and creates a list of the unique directory names and puts the list in the variable $FILES. Lastly, it goes through the list of unique directories and counts the number of occurances in the temp file, which will give you the number of small files in the directory and prints it out with the directory name. The sort at the end sorts them in reverse numerical order by number of files found.
So when you run this, you should see results like the following:
./stm/data/tools/verify 7
./stm/config/tools/verify 4
./stm/config/tools/monitor 2
./spool/pwgr 1
./opt/ignite/local 1
This will tell you the number of small files (as defined in the find command) in each directory. Hope this helps.
-JWJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2001 07:13 AM
03-16-2001 07:13 AM
Re: How to find directory with many small files?
-Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2001 04:10 AM
03-17-2001 04:10 AM
Re: How to find directory with many small files?
Jerry's script is good and will work but make sure that you specify
-size -1000c
in your find command. Without the 'c', -size refers to blocks, not bytes (characters).
--Bruce