I want to delete the specific file, std_info
under /tmp
,
if it hasn't been modified within a day (or 1440 minutes).
For now, I created the following syntax that prints only the files that were modified within one day:
find /tmp -mmin -1440 -type f -exec ls -l {} +
but how to do the opposite way?
In order to removed the std_info
file under /tmp
that wasn't modified within 1 day?
[ -e /tmp/std_info ] && find /tmp/std_info -mmin +1440 -delete
than to search through a whole directory structure for a file that does not exist. – Kusalananda Jan 05 '20 at 11:50std_info
", then don't say "a specific file namedstd_info
". – Kusalananda Jan 05 '20 at 11:54-mtime
test will test modification time in days, so-mtime +1
will match something that was modified more than 1 days ago (i.e. 2 day ago or more). See also https://unix.stackexchange.com/questions/92346/why-does-find-mtime-1-only-return-files-older-than-2-days – Kusalananda Jan 05 '20 at 12:41find
on OpenBSD won't have it while still supporting-mmin
, so I thought I'd play it safe. Isn't+1140
"more than 1440 minutes" ("1441 minutes or more")? – Kusalananda Jan 05 '20 at 15:25-mmin +1440
won't match a file that is1440.99999999
minutes old. Here, you want-mtime +0
, or-mtime +1d
with FreeBSD or! -newermt '1 day ago'
with GNUfind
at least. – Stéphane Chazelas Jan 05 '20 at 15:37+1440
is from the user. BTW, I just submitted a bug report against OpenBSD'sfind
. It does the wrong thing with-mtime +N
(it doesmtime >= N
, notmtime > N
). No wonder this has been confusing me in the past! – Kusalananda Jan 05 '20 at 15:54-atime +7
. I definitely think+N
should mean "strictly more thanN
". – Kusalananda Jan 05 '20 at 16:57