Find files that modify another file in an hour
For example, if I have 3 files, called 1.txt, 2.txt, and 3.txt, and they are created an hour apart, say 1pm, 2pm, and 3pm, respectively. What I need is a command that can find all the files that have been modified within an hour of a particular file.
I am in the same directory as the files in the terminal, and all files are setuid permissions
I’ve been working on :
Found it. -type f -perm -4000 -newer 2.txt -mmin -60 -print
This should return 3.txt but it doesn’t
What is the use of a file created within an hour before or after 2.txt?
Solution
Try this
Touch /tmp/temp -t time1
Touch /tmp/ntemp -t time2
Found it. – newer /tmp/temp -a! -newer/tmp/ntemp -exec ls -l {}\; 2>/Development/Empty
Where
time1 = file creation time – 1 hour
time2 = file creation time + 1hr
For example:
Time 1 = 201210041500
Time 2 = 201210041700