Looping through find output in Bash where file name contains white spaces

后端 未结 2 1156
广开言路
广开言路 2020-11-30 10:07

I try to search for files that may contain white spaces I try to use -print0 and set IFS here is my script



        
2条回答
  •  死守一世寂寞
    2020-11-30 10:25

    Use read -d '' -r file and set IFS only for the context of read:

    find people -name '*.svg' -print0 | while IFS= read -d '' -r file; do
        grep ' /dev/null && echo "$file" | tee -a embeded_images.txt;
    done
    

    And quote your variables.

提交回复
热议问题