处理包含两种报价类型的文本

geo*_*ory 2 bash

我想将以下文本附加到Linux中的文件:

echo He said "I can't append this" >> file.txt
cat file.txt
He said I can't append this
Run Code Online (Sandbox Code Playgroud)

我发现最接近的解决方案不起作用.如何在附加的字符串中包含两组引号?

anu*_*ava 5

最好使用here-doc来避免疯狂转义:

cat<<'EOF' > file.txt
He said "I can't append this"
EOF
Run Code Online (Sandbox Code Playgroud)