如果在其中一个文件上失败,如何从find -exec退出 [英] How to exit from find -exec if it fails on one of the files

查看:197
本文介绍了如果在其中一个文件上失败,如何从find -exec退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行命令

pre $ find $ / path -exec program \ {} \;

但是我希望命令尽快退出find命令

  program \ {} 



有没有一个简单的方法来做到这一点?

解决方案除了其他好的答案外,GNU find(至少)有一个 -quit 谓词:

  find path -other -predicates \(-exec cmd {} \; -o -quit \)

-quit 谓词是肯定是非标准的,并不存在于BSD中查找。


I want to run the command

find some/path -exec program \{} \; 

but I want the find command to quit as soon as the command

 program \{}

fails on any of the files found.

Is there a simple way of doing this?

解决方案

In addition to the other fine answers, GNU find (at least) has a -quit predicate:

find path -other -predicates \( -exec cmd {} \; -o -quit \)

The -quit predicate is certainly non-standard and does not exist in BSD find.

这篇关于如果在其中一个文件上失败,如何从find -exec退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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