Hi all,
How can I list files that has not been modified for more than 4 hours in
a directory.
Thanks in advance!
Shawn
How can I list files that has not been modified for more than 4 hours in
a directory.
Thanks in advance!
Shawn
Quote:> Hi all,
> How can I list files that has not been modified for more than 4 hours in
> a directory.
> Thanks in advance!
> Shawn
> find <dir> -mtime +4
> > Hi all,
> > How can I list files that has not been modified for more than 4 hours in
> > a directory.
> > Thanks in advance!
> > Shawn
from finds man page:
-mtime n
File's data was last modified n*24 hours ago.
So n gets to be days!! not hours as the OP originally asked.
My GNU find version 4.1 supports a -mmin option that can check
for changes in between the last minutes!
-mmin n
File's data was last modified n minutes ago.
So 'find <dir> -type f -mmin 240 -print' will print out regular
files that where modified 240 minutes (I thought this where 4 hours:-))
If your find does not support -mmin it will most probably have the
-newer
option where you can check against the modification time of an other
file.
So a workaround is to create a file with mod time 4 hours ago and to use
find with -newer! Read man touch.
Hope this helps.
Z
> > find <dir> -mtime +4
> > > Hi all,
> > > How can I list files that has not been modified for more than 4 hours
in
> > > a directory.
> > > Thanks in advance!
> > > Shawn
> I bet you're wrong! :-(
> from finds man page:
> -mtime n
> File's data was last modified n*24 hours ago.
> So n gets to be days!! not hours as the OP originally asked.
> My GNU find version 4.1 supports a -mmin option that can check
> for changes in between the last minutes!
> -mmin n
> File's data was last modified n minutes ago.
> So 'find <dir> -type f -mmin 240 -print' will print out regular
> files that where modified 240 minutes (I thought this where 4 hours:-))
> If your find does not support -mmin it will most probably have the
> -newer
> option where you can check against the modification time of an other
> file.
> So a workaround is to create a file with mod time 4 hours ago and to use
> find with -newer! Read man touch.
> Hope this helps.
> Z
but
find <dir> -type f -mmin 240 -print
is'nt corret either. It finds file that are modified exactly 4 hous ago
use 'find <dir> -type f -mmin -240 -print' instead
> > > find <dir> -mtime +4
> > > > Hi all,
> > > > How can I list files that has not been modified for more than 4 hours
> in
> > > > a directory.
> > > > Thanks in advance!
> > > > Shawn
> > I bet you're wrong! :-(
> > from finds man page:
> > -mtime n
> > File's data was last modified n*24 hours ago.
> > So n gets to be days!! not hours as the OP originally asked.
> > My GNU find version 4.1 supports a -mmin option that can check
> > for changes in between the last minutes!
> > -mmin n
> > File's data was last modified n minutes ago.
> > So 'find <dir> -type f -mmin 240 -print' will print out regular
> > files that where modified 240 minutes (I thought this where 4 hours:-))
> > If your find does not support -mmin it will most probably have the
> > -newer
> > option where you can check against the modification time of an other
> > file.
> > So a workaround is to create a file with mod time 4 hours ago and to use
> > find with -newer! Read man touch.
> > Hope this helps.
> > Z
> OOps
> that did'nt come out right !! sorry
> but
> find <dir> -type f -mmin 240 -print
> is'nt corret either. It finds file that are modified exactly 4 hous ago
> use 'find <dir> -type f -mmin -240 -print' instead
never mind, but still we're both wrong, the man page turns out to be
right!:)
Numeric arguments can be specified as
+n for greater than n,
-n for less than n,
n for exactly n.
So one will have to write:
find <dir> -type f -mmin +240 -print
to get all files that have not been modified in between the last four
hours!:-)
Yours would get the file that were modified in the past four hours.
Z
--
LISP is worth learning for the profound enlightenment experience you
will have when you finally get it; that experience will make you a
better programmer for the rest of your days. Eric S. Raymond
------------------------------------------------------------------------
_/_/_/_/_/ _/_/_/_/ from: Zoran Cutura,
_/ _/ _/ IMH-Innovative Motorentechnik Prof. Huber,
_/ _/ post: DaimlerChrysler AG, EP/VRS, X910,
_/ _/ 71059 Sindelfingen, Germany,
_/ _/ phone: +497031 90-77855
_/ _/ _/ mobil: +49171 4488407
PGP fingerprint: F0 C3 30 F4 B3 7E 22 36 1C 51 B7 60 A9 BB 23 BE
Do I guess correctly you need this in the context of some packaging
operation? Then you may want it semi-automatic: manually touch(1) a file
4 hours back and use
find . ! -newer /tmp/marker
If you don't want recursion, use a ksh loop with the -nt test operator:
for i in *
do
[[ $i -nt /tmp/marker ]] && print $i
done
Note that a bulletproof calculation of time differences (with date(1))
leads to a whole slew of portability problems, as frequently discussed
here. If you want it bullet-proof and automatic, write it in perl.
S?ren's and Zoran's finally :-) converged recommendation of GNU find +mmin
is fine if you can rely on GNU being available.
Regards,
--
Michael Sternberg | Uni-GH Paderborn
http://www.phys.uni-paderborn.de/~stern/ | FB6 Theoretische Physik
phone: +49-(0)5251-60-2329 fax: -3435 | 33098 Paderborn, Germany
"Who disturrrbs me at this time?" << Zaphod Beeblebrox IV >> <*>
Thank you for all the helps! I am very grateful.
Shawn
> If you just need it "FYI", use "ls -t", plain simple.
> Do I guess correctly you need this in the context of some packaging
> operation? Then you may want it semi-automatic: manually touch(1) a file
> 4 hours back and use
> find . ! -newer /tmp/marker
> If you don't want recursion, use a ksh loop with the -nt test operator:
> for i in *
> do
> [[ $i -nt /tmp/marker ]] && print $i
> done
> Note that a bulletproof calculation of time differences (with date(1))
> leads to a whole slew of portability problems, as frequently discussed
> here. If you want it bullet-proof and automatic, write it in perl.
> S?ren's and Zoran's finally :-) converged recommendation of GNU find +mmin
> is fine if you can rely on GNU being available.
> Regards,
> --
> Michael Sternberg | Uni-GH Paderborn
> http://www.phys.uni-paderborn.de/~stern/ | FB6 Theoretische Physik
> phone: +49-(0)5251-60-2329 fax: -3435 | 33098 Paderborn, Germany
> "Who disturrrbs me at this time?" << Zaphod Beeblebrox IV >> <*>
> Is there a way to automatically 'touch' a file that is 4 hours back of
> current time? I think my question is how to create a time stamp that
> is 4 hours back?
Here's some rumbling of guns: If you have GNU tools, touch --date='4 hours
ago' /tmp/marker; but then you probably also have GNU find which supports
+mmin and you can get by without touch altogether. Without GNU,
and if you just need this for dt = a few hours it might be enough to fiddle
with the TZ variable and call "date +%m%d%H%M". At the other extreme you
need a C program for lack of a sufficient script environment (notably
perl).
Regards,
--
Michael Sternberg, Dipl. Phys. | Uni-GH Paderborn
http://www.phys.uni-paderborn.de/~stern/ | FB6 Theoretische Physik
phone: +49-(0)5251-60-2329 fax: -3435 | 33098 Paderborn, Germany
"Who disturrrbs me at this time?" << Zaphod Beeblebrox IV >> <*>
Thank you so much for your advice!
Shawn
> > Is there a way to automatically 'touch' a file that is 4 hours back of
> > current time? I think my question is how to create a time stamp that
> > is 4 hours back?
> Please carefully re-read the previous posting again and tell us about the
> context you need this in. This is essential to get a useful answer.
> Otherwise this question leads into a bottomless pit of idle speculation
> where concept battles are fought.
> Here's some rumbling of guns: If you have GNU tools, touch --date='4 hours
> ago' /tmp/marker; but then you probably also have GNU find which supports
> +mmin and you can get by without touch altogether. Without GNU,
> and if you just need this for dt = a few hours it might be enough to fiddle
> with the TZ variable and call "date +%m%d%H%M". At the other extreme you
> need a C program for lack of a sufficient script environment (notably
> perl).
> Regards,
> --
> Michael Sternberg, Dipl. Phys. | Uni-GH Paderborn
> http://www.phys.uni-paderborn.de/~stern/ | FB6 Theoretische Physik
> phone: +49-(0)5251-60-2329 fax: -3435 | 33098 Paderborn, Germany
> "Who disturrrbs me at this time?" << Zaphod Beeblebrox IV >> <*>
> I am writing this ksh script to zip all the files that are older than X hours.
> My version of 'find' doesn't support the 'mmin' option and we have no GNU tools
> here.
Just my 0.02 worth. ;-)
Cheers,
Dave. :-)
1. files that has not been modified for 4 hours
Hi all,
How can I list files that has not been modified for 4 hours in a
directory?
Thanks
Shawn
2. Extract portions of files using awk or perl
3. How to check if a file is modified in the last hour in ksh?
5. How to find file modify time less than 12 hour?
7. Finding files modified a number of -hours- ago
8. FTP download from Sunsolve to a Linux local machine
9. Last-modify time on directories containing modified files
10. ksh: how to find/ls files older than n HOURS, not DAYS
11. Deleted files but space not freed up for several hours!
12. not tar 'ing files which are located in dir having whitespaces
13. having apache give the last-modified date?