如何在命令替换期间禁用分词?这是问题的一个简化示例:
下午 4:00 /用户/paymahn/下载 ???猫测试.txt 你好\n世界 下午 4:00 /用户/paymahn/下载 ???echo $(cat test.txt) 你好 世界 下午 4:00 /用户/paymahn/下载 ???echo "$(cat test.txt)" 你好 世界 下午 4:01 /用户/paymahn/下载 ???echo "$(cat "test.txt" )" 你好 世界
我想要的是echo $(cat test.txt)
(或包含命令替换的某些变体)输出hello\nworld
.
我发现https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html在底部说,If the substitution appears within double quotes, word splitting and filename expansion are not performed on the results.
但我似乎无法理解。我会认为我已经尝试过的示例之一符合该规则,但我想不是。