0

I am writing a bash script where i try to do a simple concatenation of 2 strings

app1.sh

FQDN=$(az containerapp show --name "app-test" --resource-group testapp --query "properties.configuration.ingress.fqdn")
FULL_URL=https://${FQDN}
         echo $FULL_URL
         output: https://"appptest.test.azurecontainerapps.io" //malformed

even if i try

   FULL_URL="https://${FQDN}"
   output: https://"appptest.test.azurecontainerapps.io" //malformed
   FQDN=https://"${FQDN}"
   output: https://"appptest.test.azurecontainerapps.io" //malformed

I have tried this in many ways,unsuccessfully i want the output to be

https://appptest.test.azurecontainerapps.io

Thanks

Coder
  • 39
  • 6
  • 1
    What exactly is the output of `az containerapp show`? This looks like what'd you see if it was returning JSON and not raw strings. (If you want to convert JSON _to_ a raw string, `jq -r .` is your friend; there are cheap-and-easy approaches using the shell's built-in parameter expansion support that'll _just_ take literal quotes out, but they won't handle special/unusual cases that `jq` does handle correctly). – Charles Duffy Oct 19 '22 at 17:05
  • BTW, I assume the backtick at the first line of your code sample is a typo? – Charles Duffy Oct 19 '22 at 17:06
  • "appptest.test.azurecontainerapps.io" //this is the output with double quotes – Coder Oct 19 '22 at 17:07
  • So `az containerapp show` includes the quotes in its output? Then it's not the slightest bit surprising that the quotes are in your variable; why would you expect anything else? – Charles Duffy Oct 19 '22 at 17:08
  • 1
    Use `fqdn=$(az containerapp show ... | jq -r .)` to convert it to a raw string. – Charles Duffy Oct 19 '22 at 17:08
  • (the lowercase variable name in the above example is intentional; all-caps names are used for variables with meaning to the shell and operating system, while names with at least one lower-case character are reserved for application use; as someone writing scripts, you're an application developer and should be in that reserved space). – Charles Duffy Oct 19 '22 at 17:09
  • I already told you how to get the final output you requested. Twice. – Charles Duffy Oct 19 '22 at 17:10

0 Answers0