Say today is April 8th and I execute the following in bash.
cd /tmp
mkdir hello
touch -d 2015-04-01 hello
Then, say I want to delete all files in /tmp that are older than one day, but NOT directories and I execute this:
find /tmp -mtime +1 -delete -type f
Why is directory "hello" deleted if it's not a file?
Thanks!
The find command executes the expression in order. Since -delete
is before -type
, -type
is never reached. Try:
find /tmp -mtime +1 -type f -delete