最近,当我阅读一个 QA时,它有一些令我意想不到的行为:
~/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
在我看来,当进行替换时,'cat findtest/file\ with\ \"double\ quotes\"'
只要替换上面的文件名就可以了file\ with\ \"double\ quotes\"
。如果我们保留引号包装器,它将显示:
$ cat "findtest/file\ with\ \"double\ quotes\""
cat: 'findtest/file\ with\ "double\ quotes"': No such file or directory
问:
该替换实际上做了什么导致上述有点奇怪的行为,其中 2 个子字符串“findtest/file with double”和“quotes”,而不是“findtest/file with”和“double quotes”作为"
分隔符?