检查目录中是否存在某种文件类型/扩展名
问题描述:
如何使用bash判断目录中是否存在特定扩展名的文件?
How would you go about telling whether files of a specific extension are present in a directory, with bash?
类似
if [ -e *.flac ]; then
echo true;
fi
答
#!/bin/bash
count=`ls -1 *.flac 2>/dev/null | wc -l`
if [ $count != 0 ]
then
echo true
fi