The single quotes mean the variable won't be expanded:
$ echo '$HOSTNAME'
$HOSTNAME
If you need to print a variable with quotes, it's easier (and generally better anyway) to use printf
:
$ printf '"%s"\n' "$HOSTNAME"
"myHost"
If you must use echo
, you can do something like this:
$ echo "\"$HOSTNAME\""
"myHost"
or this:
$ echo '"'"$HOSTNAME"'"'
"myHost"
I don't see how this is related to the curl
command you show, but if you mean you want the quoted $HOSTNAME
in the curl
command, then it should be enough to quote the entire URL, like this:
curl -I "http://localhost:8080/jobname/buildWithParameters?ENVIRONMENT=UPPER_DEV&IP=$HOSTNAME"
Or, if the server requires the quotes, you can do:
curl -I "http://localhost:8080/jobname/buildWithParameters?ENVIRONMENT=UPPER_DEV&IP='$HOSTNAME'"
But if you really, really need the double quotes, try:
curl -I "http://localhost:8080/jobname/buildWithParameters?ENVIRONMENT=UPPER_DEV&IP=\"$HOSTNAME\""
echo "\"$HOSTNAME\""
to include literal double-quotes within the double-quoted string. – ilkkachu Jun 13 '22 at 18:30curl
command looks fine to me, I guess? And you didn't ask anything about it, so do I get it right that works ok for you? – ilkkachu Jun 13 '22 at 18:31