【发布时间】:2016-09-19 05:25:55
【问题描述】:
我有一个字符串:
Str='This string has "a substring"'
字符串有逗号,所以如果我打印我看到的字符串:
echo "${Str}"
This string has "a substring".
如果我输入命令:
$ Tmp=( ${Str} )
$ echo "${Tmp[3]}"
"a
$ echo "${Tmp[4]}"
Substring"
我想打印:a Substring
有什么建议吗?
我可以更改逗号,但必须将其从 Str 打印到 Tmp
【问题讨论】:
-
您要考虑哪些字符?假设 Str 包含
'a bunch' of `various quotes` with possible "escape \"characters" or mismatched ' quotes, $metachars and $(maybe commands) .?那应该怎么分呢?
标签: bash