Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定一个变量var=toucan,我可以执行以下操作:
var=toucan
echo ${var^^} TOUCAN echo ${var:3} can
是否有可能做类似于echo ${var:3^^}得到的事情CAN?
echo ${var:3^^}
CAN
echo ${var:3^^} bash: var: 3^^: syntax error: operand expected (error token is "^")
不; bash 不允许您组合这样的特殊参数扩展(对于它们中的任何一个,包括 remove-affix、value-if-null、value-if-null-or-empty 等),您必须分两次进行步骤,或使用 bash 之外的程序。