I would like to write a bash script to decode a base64 string. For example I type decode QWxhZGRpbjpvcGVuIHNlc2FtZQ==
and it prints Aladdin:open sesame
and returns to the prompt.
So far I have tried a simple bash file containing python -m base64 -d $1
but this command expects a filename not a string. Is there another non-interactive command (not necessarily in a Python module) that I can run from the command line to achieve this, without having to install any extra packages? (Or if I do, something super-minimal.)
Best Answer
Just use the
base64
program from thecoreutils
package:Or, to include the newline character
output (includes newline):