检查目录中是否存在某种文件类型/扩展名 [英] Check whether a certain file type/extension exists in directory
本文介绍了检查目录中是否存在某种文件类型/扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用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
这篇关于检查目录中是否存在某种文件类型/扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文