Iterate over a list of files with spaces

前端 未结 11 1451
-上瘾入骨i
-上瘾入骨i 2020-11-22 05:16

I want to iterate over a list of files. This list is the result of a find command, so I came up with:

getlist() {
  for f in $(find . -iname \"f         


        
11条回答
  •  旧时难觅i
    2020-11-22 06:12

    You could replace the word-based iteration with a line-based one:

    find . -iname "foo*" | while read f
    do
        # ... loop body
    done
    

提交回复
热议问题