[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

File search

Posted on 2004-11-27
6
Medium Priority
?
224 Views
Last Modified: 2013-12-27
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
0
Comment
Question by:bt707
  • 3
  • 3
6 Comments
 
LVL 38

Expert Comment

by:wesly_chen
ID: 12685923
> 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
 

Author Comment

by:bt707
ID: 12685943
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
 

Author Comment

by:bt707
ID: 12685958
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 38

Expert Comment

by:wesly_chen
ID: 12685983
> 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
 
LVL 38

Accepted Solution

by:
wesly_chen earned 2000 total points
ID: 12686002
> 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
 

Author Comment

by:bt707
ID: 12686011
Thanks, all of these worked as good as you get.

Thanks again
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month18 days, 20 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question