相关疑难解决方法(0)

循环遍历具有特定扩展名的所有文件

for i in $(ls);do
    if [ $i = '*.java' ];then
        echo "I do something with the file $i"
    fi
done
Run Code Online (Sandbox Code Playgroud)

我想遍历当前文件夹中的每个文件,并检查它是否与特定扩展名匹配.上面的代码不起作用,你知道为什么吗?

bash glob file

99
推荐指数
4
解决办法
9万
查看次数

标签 统计

bash ×1

file ×1

glob ×1