How does `find` replace `{}` if it contains special characters like `"`?
0
votes
1
answer
74
views
Recently when I read one QA , it has some unexpected behaviors for me:
~/findtest % echo three > file\ with\ \"double\ quotes\"
~ % find findtest -type f -exec sh -c 'set -x;cat "{}"' \;
+ cat 'findtest/file with double' quotes
cat: findtest/file with double: No such file or directory
cat: quotes: No such file or directory
IMHO when doine replacement, it will do 'cat findtest/file\ with\ \"double\ quotes\"'
if just replacing the above filename file\ with\ \"double\ quotes\"
which will work. If we keep the quote wrapper, it will show:
$ cat "findtest/file\ with\ \"double\ quotes\""
cat: 'findtest/file\ with\ "double\ quotes"': No such file or directory
Q:
What does that replacement actually do causing the above a bit weird behavior with 2 substr 'findtest/file with double' and 'quotes' but not 'findtest/file with' and 'double quotes' with "
as the delimeter?
Asked by An5Drama
(173 rep)
Mar 7, 2025, 08:32 AM
Last activity: Mar 7, 2025, 10:38 AM
Last activity: Mar 7, 2025, 10:38 AM