小编Pay*_*ian的帖子

如何在命令替换期间禁用分词?

如何在命令替换期间禁用分词?这是问题的一个简化示例:

 下午 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.但我似乎无法理解。我会认为我已经尝试过的示例之一符合该规则,但我想不是。

zsh command-substitution

3
推荐指数
1
解决办法
620
查看次数

标签 统计

command-substitution ×1

zsh ×1