Had this issue while working with inline bash command and this thing got me really confused. So, say I declare a shell variable temp and give it a value:
> temp='hello'
and now to echo this result in UPPER CASE using inline commands I write
bash -c "echo ${temp^^}"
HELLO
which is totally fine and I'm okay with it. Now while studying this topic I came across this line, "Whenever we put code in a string (such as in the case of passing it in as an argument), the code should be single-quoted."
And this line is helpful as it solves the ambiguity can be caused by multiple double quotes.
So, following this I wrote the code as follows:
bash -c 'echo "${temp^^}"'
Which gave me no output. I tried to do a verbose command on this one which gave me this:
bash -cv 'echo "${temp^^}"'
echo "${temp^^}"
Can somebody explain why the result is not getting displayed as HELLO, would really appreciate it.
export temp
;) – cryptarch Mar 07 '21 at 21:33