AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
Expand all | Collapse all

Need help regarding "FIND" command.

  • 1.  Need help regarding "FIND" command.

    Posted Thu August 09, 2012 02:56 AM

    Originally posted by: s_m_gopinath


    Greetings champs,

    I am new to AIX and I need some help regarding the "Find" command. I understood that atime is access time, ctime is create time and mtime is modified time. But I don't understand what the below text describes in the atime and mtime :

    -mtime n The value of n can be one of the following:
    n - Evaluates as True if the file modification time subtracted from the initialization time, divided by 86400 seconds (with any remainder discarded), is n. 86400 seconds is 24 hours.
    -n - Evaluates as True if the file modification time subtracted from the initialization time, divided by 86400 seconds (with any remainder discarded), is less than n.
    +n - Evaluates as True if the file modification time subtracted from the initialization time, divided by 86400 seconds (with any remainder discarded), is greater than n (in case of UNIX03, greater than n+1).

    Can some one explain what it is in simple terms.

    With regards,
    Gopinath.
    #AIX-Forum


  • 2.  Re: Need help regarding "FIND" command.

    Posted Thu August 09, 2012 10:40 AM

    Originally posted by: orphy


    Think of "n" is the same as the "number of days" although, technically, it is doing things in seconds. Pay attention to the value of "n" of the -mtime parameter in the two examples below and compare the timestamps of the files found.

    In short, a "-n" will give you anything that is modified (-mtime) or accessed (-atime) within the "n" days. A "+n" will give you the files OLDER than "n" days.
    1. date
    Thu Aug 9 10:31:24 EDT 2012
    1. find /tmp -name \*.out -mtime -7 -ls|head -2
    127 3 -rw-r--r-- 1 root system 2600 Aug 8 23:59 /tmp/archive.out
    237 0 -rw-r--r-- 1 root system 0 Aug 9 00:00 /tmp/collect.out
    1. find /tmp -name \*.out -mtime +7 -ls|head -2
    28677 1 -rw-r----- 1 root system 667 Nov 17 2008 /tmp/myfile.db.out
    28686 1 -rw-r----- 1 root system 568 Nov 17 2008 /tmp/myfile.proc.out
    Orphy
    #AIX-Forum