0

I like to encode with base64 from stdin by invoking the command pasting the input and pressing Ctrl + D twice in order to avoid a trailing newline if I don't want one to be part of the input. It avoids echo and leaves no data in the shell history.

However, the output is written directly after the input and it's hard to retrieve the value:

$ base64
Input without trailing newlineSW5wdXQgd2l0aG91dCB0cmFpbGluZyBuZXdsaW5l

Is there any way I can look like

$ base64
Input without trailing newline
SW5wdXQgd2l0aG91dCB0cmFpbGluZyBuZXdsaW5l

without any newlines being included in the encoded output?

I'm using Ubuntu 23.10.

1 Answer 1

1

Here's a a little shell alias that should do what you want:

alias b64='x="$(base64)"; echo; echo "$x"'

Simply run b64 and do what you suggest in the OP.

1
  • Also added alias b64-decode='x="$(base64 --decode)"; echo; echo "$x"' Commented Nov 21, 2023 at 10:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.