0

I am trying to read the value from a file and use it in a curl command as follows:

file.sh

val=$(cat /root/file.txt)
curl -k --location --request GET 'https:MYENDPOINTHERE' --header "Authorization: $val"

when I do echo $val i get "some value" With the quotes. I think there is the issue. Hence, I think the way I am storing the value post a curl command and jq is either wrong or I need to read the value differently

The above call doesn't work. However, if I hard-code the value, it works

val="some value"
curl -k --location --request GET 'https:MYENDPOINTHERE' --header "Authorization: ${val}"

Can someone please suggest what was wrong?

harry123
  • 560
  • 1
  • 4
  • 14
  • 3
    If the quotes are actually part of the data being read from the file, they'll be passed on as part of the `Authorization` header. You'll just need to remove them from the value before passing it. Also, `echo $var` can be highly misleading; see [this question](https://stackoverflow.com/questions/29378566/i-just-assigned-a-variable-but-echo-variable-shows-something-else). – Gordon Davisson Oct 07 '21 at 22:01

0 Answers0