我如何在java中迭代文件?

时间:2015-11-06 10:08:07

标签: linux bash grep

我想做以下行动

for(File : find - ".java"){
// here i will do grep on the file, i want to process each file separetely
}

在bash中执行此操作的方法是什么?

1 个答案:

答案 0 :(得分:2)

只需使用process substitution

while IFS= read -r name;
do
    # do things with $name, which contains the name of the file
done < <(find -type f -name "*.java")