2016-03-27 41 views
0

当命令“find”进入权限被拒绝的文件夹时,如何停止脚本。当查找到达拒绝权限的文件夹时停止bash脚本

我列出了我电脑中的所有文件夹。

我想在“查找”找到权限被拒绝的文件夹时停止搜索过程。

DIRS=$(find . -type d)

非常感谢

+0

请看[这个问题的回答(http://unix.stackexchange.com/questions/225572/exit-bash-when-find-gets-to-a-folder -with-permission-denied)或[this one](http://stackoverflow.com/questions/3474526/stop-on-first-error)。 – Tym

回答

0

现在不能对此进行测试,但你应该以exec检查,如果该文件夹是可执行的。

喜欢的东西

find -type d -print0 -not -exec test -x '{}' \; -quit 
相关问题