使用循环各种扩展匹配的文件 [英] Matching files with various extensions using for loop
本文介绍了使用循环各种扩展匹配的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想匹配,遍历文件,扩展名为.txt的.h的.py。在特定的文件夹$ {arg}里。下面是我做的。
I am trying to match and loop through files with extensions .txt .h .py. in specific folder ${arg}. Here is what I did
for file in ${arg}/*.{txt, h, py}; do
...
done
但是我没有这样的文件对所有扩展,即使我有这样的文件。
However I got no such file for all extensions even though I have such files.
line 24: dir1/*.{txt,: No such file or directory
line 24: h,: No such file or directory
line 24: py}: No such file or directory
我怎么能循环,虽然使用特定扩展名的文件为
?
推荐答案
失去的空间;庆典问津。
Lose the spaces; bash cares.
for file in "${arg}"/*.{txt,h,py}; do
这篇关于使用循环各种扩展匹配的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文