Austin Group Defect Tracker

Aardvark Mark III


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001259 [1003.1(2016)/Issue7+TC2] Shell and Utilities Objection Error 2019-06-14 16:18 2019-07-25 15:08
Reporter stephane View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Resolved  
Name Stephane Chazelas
Organization
User Reference
Section find utility
Page Number 2801 (in 2018 edition)
Line Number 92124
Interp Status ---
Final Accepted Text See Note: 0004489
Summary 0001259: wrong description for find -atime +7 example
Description >  2. The following command:
>
> find / \( -name tmp -o -name '*.xx' \) -atime +7 -exec rm {} \;
>
> removes all files named tmp or ending in .xx that have not been
> accessed for seven or more 24-hour periods.

It's a classic mistake (caused by a confusing API).

-atime +7 is for files whose age as an *integer* number of days (24-hour periods) is *strictly* greater than 7, so 8 or more days.

I would choose -mtime as an example instead of of -atime as systems these days tend not to update the atime upon every access.

I would also add a ! -type d as rm cannot remove directory files without -r, and find would likely update the access time of those directories (rm would change the mtime).

I would also use + instead of \; to avoid running on rm per file.

Also note that it assumes file names are valid sequences of characters in the locale's charset.
Desired Action Change to:

      2. The following command:

       find / \( -name tmp -o -name '*.xx' \) ! -type d -mtime +6 -exec rm {} +

      removes all files whose name is tmp or ends in .xx that have not
      been modified in the last seven 24-hour periods.

It's such a common mistake, that it may be worth stressing it. Adding a:

       find / \( -name tmp -o -name '*.xx' \) ! -type d \
         \( -mtime 7 -o -mtime +7 \) -exec rm {} +

      would achieve the same result

Could help, and also to explain the rationale as to why you need -mtime +6 for more than 7 days old.

Tags tc3-2008
Attached Files

- Relationships

-  Notes
(0004423)
stephane (reporter)
2019-06-14 16:53

There's a similar problem with -size on line 92162:

find / −path /media −prune −o −size +200000 −print

finds file whose size is strictly greater than 100 000 KiB and 511 bytes (are 200001 512-byte units larger or larger). Also note that KB usually refers to 1000 bytes these days. KiB is the IEC way to make it clear we're talking of 1024-based units.

-size +199999

would be 100000 KiB or larger.

For more than 100000 KiB, that would be:

-size +102400000c
(0004489)
nick (manager)
2019-07-25 15:08

On page 2801 line 92124-5 change:
    
find / \( −name tmp −o −name '*.xx' \) −atime +7 −exec rm {} \;


    removes all files named tmp or ending in .xx that have not been accessed for seven or more 24-hour periods.

to
  
find / \( −name tmp −o −name '*.xx' \) ! -type d -mtime +7 −exec rm -f {} +


  removes all files named tmp or ending in .xx that have not been modified for more than seven (i.e. eight or more) 24-hour periods.

  
  On page 2802 change lines 92159-92160:
      
the following command searches the file hierarchy for files larger than 100 000 KB without searching any mounted removable media:

      to:
    
the following command searches the file hierarchy for files of size 100 000 KiB or larger without searching any mounted removable media:

          and change "+200000" to "+199999" at line 92162.

- Issue History
Date Modified Username Field Change
2019-06-14 16:18 stephane New Issue
2019-06-14 16:18 stephane Name => Stephane Chazelas
2019-06-14 16:18 stephane Section => find utility
2019-06-14 16:18 stephane Page Number => 2801 (in 2018 edition)
2019-06-14 16:18 stephane Line Number => 92124
2019-06-14 16:53 stephane Note Added: 0004423
2019-07-25 15:08 nick Note Added: 0004489
2019-07-25 15:08 nick Interp Status => ---
2019-07-25 15:08 nick Final Accepted Text => See Note: 0004489
2019-07-25 15:08 nick Status New => Resolved
2019-07-25 15:08 nick Resolution Open => Accepted As Marked
2019-07-25 15:08 nick Tag Attached: tc3-2008


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker