Search code examples
bashescapingglob

Is it properly quoted when I using '*' or '**/*' in bash?


find -name '*.jpg' -print0 | xargs -0 qiv

qiv **/*.jpg

both are safely escaped and delivered to qiv?


Solution

  • Yes. In the first case, find is expanding the wildcard internally, and delivering results to xargs as it expects them. In the second, the shell is expanding them and passing each match as a separate argument. Both are correct (assuming shell support for **, and that the command line length maximum isn't exceeded).