Need to check if .gz files exist in a directory
This question already has an answer here:
 Test supports using wildcards, so [ -f *.gz ] will be true if there is one file matching *.gz (and false otherwise - as @tripleee pointed out, this will fail with multiple matches; see below for a better variant).  
 Another possibility is to use if ls *.gz &>/dev/null; then ...; else ...; fi  if ls *.gz &>/dev/null; then ...; else ...; fi if ls *.gz &>/dev/null; then ...; else ...; fi (which will not throw any errors).  
上一篇: 检查一个文件是否存在于linux脚本中
下一篇: 需要检查目录中是否存在.gz文件
