使用find删除一些文件

时间:2016-03-19 21:53:53

标签: linux bash unix find

我正在尝试使用let notification = UILocalNotification() notification.fireDate = NSDate(timeIntervalSinceNow: 5) notification.repeatInterval = NSCalendarUnit.Minute notification.alertBody = "Please Look at me" notification.soundName = UILocalNotificationDefaultSoundName notification.userInfo = ["CustomField1": "w00t"] guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() else { return } 删除一些文件,如下面一行。

find

我的问题是,如果找到“file1”但不删除它,则该行返回true,只是“file2”。

我试过使用括号,但它也没有用。

1 个答案:

答案 0 :(得分:2)

当您“尝试使用括号”时,您没有显示命令行的样子。当你写:

find / -name "file1" -o -name "file2" -delete

操作顺序意味着表达式有效地成为:

( -name "file1" ) -o ( -name "file2" -delete )

当然,它只会删除file2。如果你更改括号,它应该可以正常工作:

find / \( -name "file1" -o -name "file2" \) -delete