Find files in created between a date range

后端 未结 8 974
遥遥无期
遥遥无期 2021-01-30 03:57

I use AIX via telnet here at work, and I\'d like to know how to find files in a specific folder between a date range. For example: I want to find all files in folder X that were

8条回答
  •  醉梦人生
    2021-01-30 04:42

    Explanation: Use unix command find with -ctime (creation time) flag

    The find utility recursively descends the directory tree for each path listed, evaluating an expression (composed of the 'primaries' and 'operands') in terms of each file in the tree.

    Solution: According to documenation

    -ctime n[smhdw]
                 If no units are specified, this primary evaluates to true if the difference
                 between the time of last change of file status information and the time find
                 was started, rounded up to the next full 24-hour period, is n 24-hour peri-
                 ods.
    
                 If units are specified, this primary evaluates to true if the difference
                 between the time of last change of file status information and the time find
                 was started is exactly n units.  Please refer to the -atime primary descrip-
                 tion for information on supported time units.
    

    Formula: find -ctime +[number][timeMeasurement] -ctime -[number][timeMeasurment]

    Examples:

    1.Find everything that were created after 1 week ago ago and before 2 weeks ago

    find / -ctime +1w -ctime -2w

    2.Find all javascript files (.js) in current directory that were created between 1 day ago to 3 days ago

    find . -name "*\.js" -type f -ctime +1d -ctime -3d

提交回复
热议问题