- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Identifying dirs with lots of 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
11-04-2003 03:27 AM
11-04-2003 03:27 AM
I've discovered the du command which is somewhat helpful, but would like a command /script that tells me the number of files in all directories.
Thank you...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2003 03:33 AM
11-04-2003 03:33 AM
Re: Identifying dirs with lots of files
echo "directory counts" > /tmp/dircount.out
for dir in `find /start_point -type d`
do
ll $dir |wc -l >> /tmp/dircount.out
done
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2003 03:35 AM
11-04-2003 03:35 AM
Re: Identifying dirs with lots of files
This script is not too much of a problem if you start with the "ls -lR" command but I'm concerned that it is a really uncommon thing to do. In most cases, files on a unix system that are good targets for deleteion are in /tmp and /var/tmp and perhaps users home directories.
I think what will be more useful for you is the "find" command. This will allow you search for large files, or files that haven't been modified in ages or files called "core" (very good target for deletion that one) and the deletion can be combined into one command. For example to delete all files on the system called core.
find / -name core -exec rm {} \;
Maybe you need to look at the man page for "find" and perhaps find where redundant files reside. I think number of files in a directory is a bit of a blunt tool.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2003 03:37 AM
11-04-2003 03:37 AM
Re: Identifying dirs with lots of files
do
echo "$dir"; ls -l $dir|wc -l
done
HTH,
Umapathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2003 03:39 AM
11-04-2003 03:39 AM
Re: Identifying dirs with lots of files
#!/usr/bin/sh
typeset -i10 BIG=500 # defines what you call "lots of files"
find . -type d | while read X
do
typeset -10 KNT=$(ls -a ${X} | wc -l)
if [[ ${KNT} -ge ${BIG} ]]
then
echo "${X}\t${KNT}"
fi
done
You can change find . to find / to do this from the root directory. You could simplify this using find -type d -size +30000c but that is not qa good test because directories that have had many files removed will still be large.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2003 03:51 AM
11-04-2003 03:51 AM
Re: Identifying dirs with lots of files
find / -type d -links +1000 -print
The link count includes directories and files, so this could find directories with 1000 sub-directories and no files, but that would be unusual.
HTH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2003 03:57 AM