File search

I have a directory on a solaris box that has about 15 sub directorys in it, In the sub directorys the files go from a few hundred to 100K, this is mail folders so the numbers change regularly.

I need a command or script that will tell me the totoal number of files that is in each directory and the total number of files that is in all of them, also which files is the 10 or 15 oldest files.


Ex:

ls /mailqueue

01  02  03  04  05  06  07  08  09  ect, ect


Thanks
bt707Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wesly_chenCommented:
> totoal number of files that is in each directory
for dirs in `find <path to direcotry> -type d -depth` ; do echo $dirs; ls -Al $dirs | wc -l; done

> the total number of files that is in all of them
find <path to direcotry> -type -f | wc -l

Wesly
0
bt707Author Commented:
those two worked great but the main thing is I need to find witch file in the sub directories is the oldest file, would like to find the oldest 10 files but the one that is the oldest would do.

Thanks,
0
bt707Author Commented:
also when i run this command
find <path to direcotry> -type -f | wc -l

it tells me how many sub directories is in the main directory, i'd like to find the total number of files in all the sub directories together.

Thanks agian

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

wesly_chenCommented:
> find <path to direcotry> -type -f | wc -l
                                              ^^
Oops, there is a typo. Should be
find <path to direcotry> -type f | wc -l

Wesly
0
wesly_chenCommented:
> in the sub directories is the oldest file, would like to find the oldest 10 files
oldest 10 files :
for dirs in `find <path to direcotry> -type d -depth` ; do echo $dirs; ls -Altr $dirs | tail -10; done
oldest file:
for dirs in `find <path to direcotry> -type d -depth` ; do echo $dirs; ls -Altr $dirs | tail -1; done

Wesly
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bt707Author Commented:
Thanks, all of these worked as good as you get.

Thanks again
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.