Reputation: 21
I want to replace KEY in curl command with variable value in shell script.
KEY=KEY_VALUE
My curl command is as follow.
curl -s "https://api.kite.trade/quote?i=NSE:NIFTY+50&i=NSE:INF" -H "X-Kite-Version: 3" -H "Authorization: token XYZ:KEY"
Thanks in advance
Upvotes: 1
Views: 1620
Reputation: 212346
Fix your quotes and use the variable:
key=key_value
curl -s 'https://api.kite.trade/quote?i=NSE:NIFTY+50&i=NSE:INF' \
-H 'X-Kite-Version: 3' -H "Authorization: token XYZ:${key}"
Use single quotes for strings that aren't interpolated (this allows you to not need to worry about whether or not there are any characters in the string that may be modified by interpolation, eg backslashes or dollar signs), and don't use variables with all cap names.
Upvotes: 1