I'm attempting to base64 encode a user:password string in a bash script, however the results in the script are different than if I run the command in a shell.
In shell (expected output):
echo -n "user:password" | base64
dXNlcjpwYXNzd29yZA==
In script (w/ -n):
USER=$(echo -n "user:password" | base64)
echo $USER
LW4gdXNlcjpwYXNzd29yZAo=
In script (w/o -n, extra character at end):
USER=$(echo "user:password" | base64)
echo $USER
dXNlcjpwYXNzd29yZAo=
Can someone tell me what I'm missing here. Thanks