how to find the modified files before 60 mins?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to find the modified files before 60 mins?
# 1  
Old 12-11-2008
how to find the modified files before 60 mins?

hi,

I need to find all the modified files before 60 minutes in a folder.

Is that possible to find using mtime in minutes?

Suggestions please.

Thanks for looking into it...

Geetha
# 2  
Old 12-11-2008
Hammer & Screwdriver Here is one way of approaching

Code:
> cat time106.sh
#! /usr/bin/bash

touch file106
current=$(stat -c %Y file106)

for myfile in file1*
   do
   filetime=$(stat -c %Y $myfile)
   filediff=$(echo $current - $filetime | bc)
   if [ $filediff -le 3600 ]
      then
      ls $myfile
   fi
done

Note that I touch a file "file106" that gets returned as being within 3600 seconds - obviously. Also note that I am only checking in this example for file1* while you may only want to use * or some other filter.
# 3  
Old 12-11-2008
hi joeyg,

I received an error message while executing the code
And this is d error message
time106.sh: syntax error at line 4: `(' unexpected

I'm using KSH, will stat go with KSH?

Many thanks,
Geetha
# 4  
Old 12-11-2008
Hammer & Screwdriver Change the format of a couple of the lines

Instead of coding like
Code:
current=$(stat -c %Y file106)

use
Code:
current=`stat -c %Y file106`

There are probably a few places this change would be necessary.

Note that the ` is the character (back-tick) normally near the top left of your keyboard and next to the 1 and NOT the character (single-quote) near the L. Many people use the wrong key.
# 5  
Old 12-11-2008
Yes joeyg, I have done those changes with back tick. Even then, its throwing error messages like,
time106.sh: stat: not found
time106.sh: stat: not found
syntax error on line 1, teletype
time106.sh: test: argument expected

Last edited by iamgeethuj; 12-15-2008 at 04:38 AM..
# 6  
Old 12-11-2008
this will do i guess
Code:
find . -type f -mmin -60 -exec ls -lrt {} \;

# 7  
Old 12-12-2008
You can run above command by watch. It will list the files dynamically.


watch -n 60 'find . -type f -mmin -60 -exec ls -lrt {} \; 2>/dev/null'
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to find directory is getting files in every 10 mins, if not then when last time file received

Dears, I am looking for a script which will work as a watch directory. I ha directory which keep getting files in every 10 mins and some time delay. I want to monitor if the directory getting the files in every 10 mins if not captured the last received file time and calculate the delay. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies

2. UNIX for Advanced & Expert Users

Find files modified in previous minute only

Hi, How can I get files which are modified only in last minute ? it should not display 2 minutes back filels -la -rw-rw-r-- 1 stuser st 51 Dec 3 09:22 a.csv -rw-rw-r-- 1 stiser st 50 Dec 3 09:25 b.csv -rw-rw-r-- 1 stuser st 53 Dec 3 09:33 c.csv When I run command at 9:34am then I... (7 Replies)
Discussion started by: sbjv
7 Replies

3. Shell Programming and Scripting

Find list of files modified for a given day ?

find list of files modified for a given day ? if i have 10 files in my directory, i have modified only 5 ... how to display only modified files ? (1 Reply)
Discussion started by: only4satish
1 Replies

4. UNIX for Advanced & Expert Users

find files modified by hours instead of minutes

Is there an easy way to find files modified by hours? If you wanted to find something modified by like 28 hours then I know you could do this: find . -mmin -1440It is pain to break out a calculator and calculate in minutes. Could you do something similar to this? I know I don't have the right... (1 Reply)
Discussion started by: cokedude
1 Replies

5. Shell Programming and Scripting

Find files modified in last hour sunOS 5.10

trying to find a way to locate files modified in the last hour in a shell script, unfortunately the command 'find . -mmin -60' is not supported on SunOS 5.10 (works on OpenSolaris 5.11 :mad:) Does anyone know a method of doing this in shell script on 5.10? cheers (19 Replies)
Discussion started by: rich@ardz
19 Replies

6. UNIX for Dummies Questions & Answers

Find last modified date for many files

Hello all - I've looked and have not been able to find a "find" command that will list the last modified date of files within a specific directory and its subdirectories. If anyone knows of such a command it would be very much appreciated! If possible, I would like to sort this output and have... (5 Replies)
Discussion started by: MichaelH3947
5 Replies

7. Shell Programming and Scripting

help: find and modified files script

hello all im a newbie in the linux world ..i have just started creating basic scripts in linux ..i am using rhel 5 ..the thing is i wanted to create a find script where i could find the last modified file and directory in the directory given as input by the user and storing the output in a file so... (6 Replies)
Discussion started by: tarunicon
6 Replies

8. Shell Programming and Scripting

find files modified more than a day

Hi All, I am using the below command to check the files modified within last 24hours find /home/karthik -mtime -1 -type f -exec ls -l {} \; What parameter do i need to add in the above command to check the files modified in last 2 or 3 days Kindly let me know if any other alternative... (2 Replies)
Discussion started by: karthikn7974
2 Replies

9. Shell Programming and Scripting

Finding files which are modified few mins ago

Hi All, I have a requirement to find out the files which are modified in the last 10 minutes. I tried the find command with -amin and -mmin options, but its not working on my AIX server. Can anyone of you could help me. Thanks in advance for your help. Raju (3 Replies)
Discussion started by: rajus19
3 Replies

10. UNIX for Advanced & Expert Users

find files modified in a specific month

hello i need a way to list files modified in a specific month and move them to a specific directry , i mean somthing like : find . -modifiedtime "May" -print -exec /usr/bin/mv newdirectory thank u (1 Reply)
Discussion started by: omer_ome
1 Replies
Login or Register to Ask a Question