gpt4 book ai didi

linux - 我如何像在 java 中一样迭代文件?

转载 作者:太空宇宙 更新时间:2023-11-04 09:29:00 24 4
gpt4 key购买 nike

我想做以下 Action

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

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

最佳答案

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

关于linux - 我如何像在 java 中一样迭代文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33564231/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com