Anonymous | Login | 2025-02-14 16:48 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||
ID | Category | Severity | Type | Date Submitted | Last Update | ||
0001259 | [1003.1(2016/18)/Issue7+TC2] Shell and Utilities | Objection | Error | 2019-06-14 16:18 | 2024-06-11 09:08 | ||
Reporter | stephane | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Accepted As Marked | ||||
Status | Closed | ||||||
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 | |||||||
|
![]() |
|||||||
|
![]() |
|||
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 | |
2019-11-20 16:04 | geoffclare | Status | Resolved => Applied |
2023-11-27 16:19 | nick | Relationship added | related to 0001777 |
2024-06-11 09:08 | agadmin | Status | Applied => Closed |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |