How to base64 encode image in linux bash / shell

前端 未结 6 1858
说谎
说谎 2021-01-29 23:30

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

6条回答
  •  一向
    一向 (楼主)
    2021-01-29 23:42

    If you need input from termial, try this

    lc=`echo -n "xxx_${yyy}_iOS" |  base64`
    

    -n option will not input "\n" character to base64 command.

提交回复
热议问题