1833003 Members
2167 Online
110048 Solutions
New Discussion

Re: count files created

 
Pando
Regular Advisor

count files created

Dear Gurus,
I have a files created everyday. And i would like to have a trend how many files are created each day.
I would like to ask for counting files everyday including the files created yesterday or a month ago?
Is this possible?

Maximum points for all correct replies.
5 REPLIES 5
Thayanidhi
Honored Contributor

Re: count files created

Hi,

What about
"find / -name *.* -print -ctime...."

Use ctime ->created time
atime -> accesed time
mtime -> modified time

with appropriate time value

Pipe to a "wc -l" to get the count.

Refer to manpage of find.

Just a thought.

Regds
TT
Attitude (not aptitude) determines altitude.
Indira Aramandla
Honored Contributor

Re: count files created

Hi Fernando,

To find the file count in a directory you can do this.

ls -l | wc -l. This will give the number of file count in the directory.

If you want the number of file for a particular period, then do this.

For example the file names have log as a common string.
find . -name "*log*" -mtime +3 -exec ls -l {} \; | wc -l

This will give the count for files called as *log* with modified date as 3 days back.


Indira A


Never give up, Keep Trying
Suraj Singh_1
Trusted Contributor

Re: count files created

Hi All,

I see a problem in using find command here, any option like -mtime, -atime or -ctime would give the output as n-1 to n multiples of 24 hrs, where 'n' is the nubner specified after say -ctime.

Thus giving -ctime 1 would give all the files created since current time previous day.

What Fernando needs is only files created today. We would need to write a script which checks the file create date with current date kind of logic.

Regards
What we cannot speak about we must pass over in silence.
Pando
Regular Advisor

Re: count files created

Is there a way to list the date of the file creation?
john korterman
Honored Contributor

Re: count files created

Hi Fernando,

unfortunately, unix does not register any data concerning file creation time: you only have the last time the content of the file was modified, the last time the file itself was accessed, and the last time the inode info of the file was modified.
The last time the inode info was modified is probably your best chance, as it may coincide with the creation time of the file. However, if anyone has changed access rights, user/group relationships etc. after file creation time - and you cannot tell if that is the case - it will of course not work.

regards,
John K.
it would be nice if you always got a second chance