如果使用Bash的目录为空,则不显示结果 [英] Do not show results if directory is empty using Bash
本文介绍了如果使用Bash的目录为空,则不显示结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,在空目录中尝试以下命令:
For example, try following command in an empty directory:
$ for i in *; do echo $i; done
*
有没有一种方法可以抑制*
的打印输出?
Is there a way to suppress the printout of *
?
推荐答案
设置 nullglob
shopt -s nullglob
for i in *; do echo "$i"; done
这篇关于如果使用Bash的目录为空,则不显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文