Operating System - HP-UX
1747988 Members
4969 Online
108756 Solutions
New Discussion

Re: -mtime+1 does not return expected results

 
Alok_Behria
Advisor

-mtime+1 does not return expected results

 

Hi All,

 

OS :- HPUX 11.11

 

I have following files with the extention of *.aud.  I was trying to find out *auf files older than 1 days. I used the following command in order to get the desired result, but the below query didn't behave the way, it should be. Please help me, where i get this wrong ?

 

      1325 Sep 15 11:43 ora_18256.aud
       658 Sep 15 11:43 ora_20226.aud
      1323 Sep 15 11:43 ora_20125.aud
       661 Sep 15 11:43 ora_20123.aud
      1989 Sep 15 11:43 ora_20088.aud
      1969 Sep 15 11:43 ora_20098.aud
       230 Sep 16 15:03 fdr_tables.sh
     40770 Sep 16 16:18 drop_objects.sql
   1423212 Sep 16 16:49 fdrb_tables.sql
     10405 Sep 16 16:56 fdrb_status.sql
       391 Sep 17 04:28 test.sh

cpmqa> find *.aud* -type f -mtime +1 -exec ls -ltr {} +
oradev1 oracpmqa /db/cpmqa/export/backup

 

4 REPLIES 4
James R. Ferguson
Acclaimed Contributor

Re: -mtime+1 does not return expected results

Hi:

 

You want:

 

find . -name "*.aud*" -type f -mtime +1 -exec ls -ltr {} +

That is, look in the current directory for files ('-type f' whose basename matches ".aud" and whose last modification time is (24-hours) or older.  The "-name', '-type' and '-mtime' specifications are ANDed together.

 

Your problem was that 'find *.aud* ...' says to 'find' in the path(s) that the shell discovered by expanding "*.aud*" whereas you wanted to match names to this pattern.

 

Re-read the 'find' manpages and practice with some cases of your own.

 

Regards!

 

...JRF...

Dennis Handly
Acclaimed Contributor

Re: -mtime+1 does not return expected results

>Your problem was that 'find *.aud* ...' says to 'find' in the path(s) that the shell discovered by expanding "*.aud*" whereas you wanted to match names to this pattern.

 

 There is nothing wrong with using the pattern in the list of files to search, provided you don't want to descend into subdirectories.  (Unless there are too many of those files or you figure that having the both the shell and find(1) doing the search is excessive.)

James R. Ferguson
Acclaimed Contributor

Re: -mtime+1 does not return expected results


@Dennis Handly wrote:

 There is nothing wrong with using the pattern in the list of files to search, provided you don't want to descend into subdirectories.


Right, but the OP's description of "I have following files with the extention of *.aud.  I was trying to find out *auf files older than 1 days." suggests that only files with that extension are desired.  The output shown includes other suffixes.  Of course given the problem description provided we are both left to guess a bit :-)

 

Regards!

 

...JRF...

Dennis Handly
Acclaimed Contributor

Re: -mtime+1 does not return expected results

>the OP's description of  "I was trying to find out *auf files older than 1 days." suggests that only files with that extension are desired.

 

(I assumed it was a typo and you must have too, since you have: -name "*.aud*")

 

>The output shown includes other suffixes.

 

I assumed that was the input.

 

>Of course given the problem description provided we are both left to guess a bit :-)

 

Yes.  Not sure what was input or output.