I\'m trying to base64 encode an image in a shell script and put it into variable:
test=\"$(printf DSC_0251.JPG | base64)\" echo $test RFNDXzAyNTEuSlBH
You need to use cat to get the contents of the file named 'DSC_0251.JPG', rather than the filename itself.
cat
test="$(cat DSC_0251.JPG | base64)"
However, base64 can read from the file itself:
base64
test=$( base64 DSC_0251.JPG )