How to use find on dirs with white spaces?

前端 未结 3 1543
情话喂你
情话喂你 2020-12-19 21:25

Here is something strange.

mkdir -p \"1/2 3/4\"
touch 1/2\\ 3/4/file.jpg
for f in $(find . -type f -name \\*jpg); do echo \"${f}\"; done

Th

3条回答
  •  心在旅途
    2020-12-19 21:42

    You can use the -print0 option along with xargs -0. For instance:

    find . -type f -name \*.jpg -print0 | xargs -0 echo
    

    This would work no matter the content of the file names (even newlines would be handled correctly).

提交回复
热议问题