I'm writing a small shell script like this:
curl -X POST --header 'Bearer "$(printf user:pass | base64)"' 'https://api.com/v1/auth'
To debug I switched to echo:
echo 'Bearer "$(printf remote-key-sync:2klic-hlqDZPGmqJTwhqVkPubld9ReXAnQSks | base64)"'
But the result is:
Bearer "$(printf remote-key-sync:2klic-hlqDZPGmqJTwhqVkPubld9ReXAnQSks | base64)"
How can I update my curl command so that it sends --header 'Bearer myBase64String' with the subshell results inside the single quote?
$()
would not be executed by bash. Replace them with double quotes instead.$(printf user:pass | base64)
, not the base64-encoded credentials.