Operating System - Linux
1751851 Members
5384 Online
108782 Solutions
New Discussion юеВ

Re: Need the list of files which created in specific time

 
SOLVED
Go to solution
VVS
Regular Advisor

Need the list of files which created in specific time

Hi all
I need the list of files which created in specific time.
Foe example: I need list of files in perticular directory which are created in last 1 hour.


Thanks
Work is life, you know, and without it, there's nothing but fear and insecurity.
13 REPLIES 13
Dennis Handly
Acclaimed Contributor

Re: Need the list of files which created in specific time

You can't get that info. You can only get a list of files modified in the last hour.

To do this, you would have to use touch to create a reference file of exactly one hour ago, then use "find . -newer ref-file".
James R. Ferguson
Acclaimed Contributor

Re: Need the list of files which created in specific time

Hi:

With Perl, this is easy:

# perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -M _ <= 1/24},@ARGV)' /path

THis will search the directory or directories passed as the script argument looking for FILES that were *modified* during the last hour (1/24 of a day).

By the way, there is no such thing as a creatino timestamp in Unix. The 'mtime' or last modification timestamp is equivalent to a creation moment when a file is first instantiated. Thereafter, any change in the file's contents updates the 'mtime' in its inode.

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Need the list of files which created in specific time

Hi (again):

Was there something more that you wanted in your solution?

Regards!

...JRF...
OFC_EDM
Respected Contributor

Re: Need the list of files which created in specific time

Hi James,

I tried your command and it doesn't work for me. I tried both relative and absolute path.

Does this have to be run in a script or is it good to run at the prompt?


Cheers
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: Need the list of files which created in specific time

Correction

It returns nothing on HPUX 11.11

on my 11.23 (recently patched) system
it does

# /usr/bin/perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -M _ <:q= 1/24},@ARGV)' /tmp
syntax error at -e line 1, near "<:"
Can't find string terminator "=" anywhere before EOF at -e line 1.
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: Need the list of files which created in specific time

Correction

doesn work on hpux 11.11

on my 11.23 system it does th is

# /usr/bin/perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -M _ <:q= 1/24},@ARGV)' /tmp
syntax error at -e line 1, near "<:"
Can't find string terminator "=" anywhere before EOF at -e line 1.
The Devil is in the detail.
VVS
Regular Advisor

Re: Need the list of files which created in specific time

hi James
Thanks for ur reply
I have 11.11 version of HP-Ux. So will it run on the same?
And can I add this line in may script?
Another one is , Is there any cmd shows the files modified in last one hour in perticular directory

Thanks
Work is life, you know, and without it, there's nothing but fear and insecurity.
James R. Ferguson
Acclaimed Contributor
Solution

Re: Need the list of files which created in specific time

Hi (again):

> Vasu: I have 11.11 version of HP-Ux. So will it run on the same?

Yes, Perl should have been part of your 11i installation and hence my script will run.

> Vasu: Is there any cmd shows the files modified in last one hour in perticular directory?

Yes, this is the original script I posted for you. Simply pass the name of the directory you want to examine as the argument to the script. In the example I showd, I used '/path' as a generic argument label. You could use '/home' or '/home/vasu' or anything that is a directory.

> O'Kevin: Copy-and-paste my post and provide the directory or directories you are interested in examining as arguments. The absence of any output means that there were no files meeting the criteria.

Regards!

...JRF...
VVS
Regular Advisor

Re: Need the list of files which created in specific time

hi
I got following error on my system
Can't locate File/Find.pm in @INC (@INC contains: /opt/perl5/lib/5.00502/PA-RISC1.1 /opt/perl5/lib/5.00502 /opt/perl5/lib/site_perl/5.005/PA-RISC1.1 /opt/perl5/lib/site_perl/5.005 .).
BEGIN failed--compilation aborted.


Please provide solution

Thanks
Work is life, you know, and without it, there's nothing but fear and insecurity.