如果输出为空,我想返回退出状态0,否则返回1:
find /this/is/a/path/ -name core.*
Run Code Online (Sandbox Code Playgroud)
Rob*_*vis 15
当你说你希望它返回一个特定的号码时,你指的是退出状态吗?如果是这样:
[[ -z `find /this/is/a/path/ -name core.*` ]]
Run Code Online (Sandbox Code Playgroud)
由于您只关心是/否响应,您可能希望将您的查找更改为:
[[ -z `find /this/is/a/path/ -name core.* -print -quit` ]]
Run Code Online (Sandbox Code Playgroud)
在找到第一个核心文件后将停止.如果没有它,如果根目录很大,查找可能需要一段时间.
这是我的版本。:)
[ -z "$(find /this/is/a/path/ -name 'core.*')" ] && true
Run Code Online (Sandbox Code Playgroud)
为简洁而编辑:
[ -z "$(find /this/is/a/path/ -name 'core.*')" ]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15469 次 |
| 最近记录: |