庆典发现​​,只有删除文件 - 参​​数顺序 [英] bash find, only delete files - order of arguments

查看:153
本文介绍了庆典发现​​,只有删除文件 - 参​​数顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天要说的是4月8日,我执行在bash下面。

Say today is April 8th and I execute the following in bash.

cd /tmp
mkdir hello
touch -d 2015-04-01 hello

然后,说我要删除/ tmp中年纪超过一天的所有文件,而不是目录和我执行此:

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?

谢谢!

推荐答案

find命令,以执行前pression。由于 -delete 为前是从来没有达到过。尝试:

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 

这篇关于庆典发现​​,只有删除文件 - 参​​数顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆