Solved

find  unix command question

Posted on 2010-09-14
13
286 Views
Last Modified: 2012-05-10

find . -mtime -1 -print will printfiles modified in the past 1 day...

how do i find files modified in past x hrs? say 2 hrs?

0
Comment
Question by:Vlearns
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +3
13 Comments
 

Author Comment

by:Vlearns
ID: 33677810
i am trying to use this in a  perl script
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 166 total points
ID: 33677843
Use -mmin (min = minutes) instead of mtime.


0
 

Author Comment

by:Vlearns
ID: 33677858
find  /tmp/yautoprof/reports/imap_auth  -mtime -1h   thi works too
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 5

Expert Comment

by:_-MYFOX-_
ID: 33677860
find . -type f -mmin -120
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33677875
>> -mtime -1h   this works too <<

Are you sure? It doesn't work for me. the "h" is silently ignored.
0
 
LVL 84

Accepted Solution

by:
ozo earned 167 total points
ID: 33678171
use File::Find;
$\=$/;
find(sub{(-M _) < 2/24 && print}, '/tmp/yautoprof/reports/imap_auth');
0
 
LVL 48

Expert Comment

by:Tintin
ID: 33678643
Note that mmin is a GNU extension to find, so depending on what *nix flavour you are using, it make not have it, in which case use ozo's Perl solution.
0
 
LVL 84

Expert Comment

by:ozo
ID: 33678667
you could also touch a file and use -newer
but since you are trying to use this in a  perl script, you might as well use perl functions
0
 

Assisted Solution

by:ChendurDasan
ChendurDasan earned 167 total points
ID: 33682553
Please try this for a recursive search. You can also use glob and restrict to currend dir

use File::Find;
use File::Copy;

my $now = time;

sub search {
$stamp = (stat($_))[9];
if  (( $now - $stamp ) < ( 24 * 60 * 60 )) {
print "Copying ". $_ . "\n" ;
copy ($_ , "" );
}
}

find (\&search , "." );
0
 

Expert Comment

by:ChendurDasan
ID: 33682561
Please try this for a recursive search. You can also use glob and restrict to currend dir

use File::Find;
use File::Copy;

my $now = time;

sub search {
$stamp = (stat($_))[9];
if  (( $now - $stamp ) < ( 24 * 60 * 60 )) {
print "Copying ". $_ . "\n" ;
copy ($_ , "" );
}
}

find (\&search , "." );
0
 

Author Comment

by:Vlearns
ID: 33720282
you could also touch a file and use -newer
but since you are trying to use this in a  perl script, you might as well use perl functions

not sure how to implement this one...any ideas...thanks!
0
 
LVL 84

Expert Comment

by:ozo
ID: 33723319
http:#a33678171 and http:#a33682553 implement this
0
 

Author Closing Comment

by:Vlearns
ID: 33774718
thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Linux Samba using Kerberos to Auth from Active Directory 9 117
SSH in linux 9 88
check the file dates in unix 14 72
78 files, need to delete row 2 in every file 3 26
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question