gpt4 book ai didi

linux - 检查目录中是否存在某种文件类型/扩展名

转载 作者:IT老高 更新时间:2023-10-28 12:31:17 28 4
gpt4 key购买 nike

您将如何使用 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

关于linux - 检查目录中是否存在某种文件类型/扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3856747/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com