3

Given a variable var=toucan I can do the following:

echo ${var^^}
TOUCAN
echo ${var:3}
can

Is it possible to do something similar to echo ${var:3^^} to get CAN?

echo ${var:3^^}
bash: var: 3^^: syntax error: operand expected (error token is "^")
Matt Simons
  • 384
  • 3
  • 8

1 Answers1

2

No; bash doesn't let you combine special parameter expansions like that (for any of them, including remove-affix, value-if-null, value-if-null-or-empty, etc.) You will have to do it in two steps, or use a program outside of bash.

Mark Reed
  • 91,912
  • 16
  • 138
  • 175