击:遍历所有带有特定扩展名的文件 [英] Bash: loop through all the files with a specific extension

查看:101
本文介绍了击:遍历所有带有特定扩展名的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我想通过在当前文件夹中的每个文件循环并检查它特定的分机相匹配。在code以上不工作,你知道为什么吗?

I want to loop through each file in the current folder and check if it matches a specific extension. The code above doesn't work, do you know why?

推荐答案

没有花哨的技巧需要:

for i in *.java; do
    ...
done

这篇关于击:遍历所有带有特定扩展名的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆