在Bash中处理双引号的方法有很多种。下面是一些常用的解决方法:
variable="This is a \"quoted\" string."
echo $variable
输出:
This is a "quoted" string.
variable='This is a "quoted" string.'
echo $variable
输出:
This is a "quoted" string.
part1="This is a "
part2="quoted"
part3=" string."
variable=$part1$part2$part3
echo $variable
输出:
This is a quoted string.
variable=$(cat <
输出:
This is a "quoted" string.
注意:在使用Here文档时,开头的标识符和结束的标识符必须是相同的,且在开始和结束标识符时不能有任何空格。
这些方法可以帮助您在Bash中处理双引号。根据具体的场景和需求,选择合适的方法来处理双引号。