Or you can turn on the nullglob (mentioned by Etan Reisner) and dotglob altogether:shopt -s nullglob dotglob#This goes before first loop.摘自Bash手册 nullglob nullglob如果设置,则Bash允许扩展没有文件匹配的文件名模式 设置为空字符串,而不是它们本身.If set, Bash allows filename patterns which match no files to expand to a null string, rather than themselves. dotglob如果已设置,则Bash在以下结果中会包含以."开头的文件名 文件名扩展.If set, Bash includes filenames beginning with a ‘.’ in the results of filename expansion.注意:dotglob包含隐藏文件(文件名开头带有.的文件)Note: dotglob includes hidden files (files with a . at the beginning in their names) 这篇关于在Bash中循环播放空目录内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 06:36