Operating System - HP-UX
1821630 Members
3235 Online
109633 Solutions
New Discussion юеВ

finding files changed between specific times

 
SOLVED
Go to solution
bhavin asokan
Honored Contributor

finding files changed between specific times

hi all,

is there anyway to find out files modified / created between specific times.
eg: at 3pm i want to find and copy files which has been modified /created betten 1pm to 2pm.

regds,
bhavin
4 REPLIES 4
Simon Hargrave
Honored Contributor
Solution

Re: finding files changed between specific times

Create 2 files with timestamps of the begin and end times you want to search, eg: -

touch start 06171300
touch end 06171400

then execute: -

find . -newer start -a ! -newer end

This will find all files from current directory who's modified date is after "start"'s timestamp, AND NOT after "end"'s timestamp.

Sy
Muthukumar_5
Honored Contributor

Re: finding files changed between specific times

Hai,

You can get the modified files as

find / -type f -mtime

If you want to know the files modified at 1- 2 pm you to execute this 2:01 PM.

Else we can go for common method as,

find / -type f | while read line; do

Get the file value with ll or ls -l
Get the date with date coomand and check for the month and date.

Problem with the ls -l or ll that
===== man ls ========
If the time of last modification is greater
than six months ago, or any time in the future, the year is
substituted for the hour and minute of the modification
time.
======================


If you are going to detect the files from root to leaf directory then this operation will take some time.

Regards,
Muthukumar
Easy to suggest when don't know about the problem!
Manish Srivastava
Trusted Contributor

Re: finding files changed between specific times

Hi Bhavin,

You can use ls -ltc to get the list of files sorted on ctime. This can be used to find the the time of creation/modification of the file.

see manpage of ls

manish
Muthukumar_5
Honored Contributor

Re: finding files changed between specific times

Hai,

Let us come to feasible solution.

Create the file with 01.00 PM with touch

as touch -t 06180100 start (MMDDHHMM)

end file as
touch -t 06180200 end


Use the find command to find only the files as
find / -type f -newer start ! -a -newer end

It will give the created / modified (only the ) files in the duration


Regards,
Muthukumar.
Easy to suggest when don't know about the problem!