I am trying to find a way to capitalize and replace dashes of a string in one echo. I do not have the ability to use multiple lines for reassigning the string value.
For example:
string='test-e2e-uber'
needs to echo $string
as TEST_E2E_UBER
I currently can do one or the other by utilizing
${string^^}
for capitalization
${string//-/_}
for replacement
However, when I try to combine them it does not appear to work (bad substitution error). Is there a correct syntax to achieve this?
echo ${string^^//-/_}
This does not answer directly your question, but still following script achieves what you wanted :
declare -u string='test-e2e-uber'
echo ${string//-/_}