【问题标题】:how i can iterate on files as in for in java?我如何像在java中那样迭代文件?
【发布时间】:2015-11-06 18:12:20
【问题描述】:

我想做下面的动作

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

在 bash 中有什么方法可以做到这一点?

【问题讨论】:

    标签: linux bash grep


    【解决方案1】:

    只需使用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")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-23
      • 1970-01-01
      • 2012-07-03
      • 1970-01-01
      • 2013-12-05
      • 1970-01-01
      • 1970-01-01
      • 2020-06-05
      相关资源
      最近更新 更多