Categories
Linux Mastering Development

Remove newline character after pipe

I want to do Base64 encode with a command

echo -en "my_message" | openssl sha1 -hmac "secret_key" | base64

The output string of openssl is as expected, but the output of base64 is not as the output from openssl has a new line character. If I run the command

echo -en "my_message" | openssl sha1 -hmac "secret_key" | xargs echo -e | base64

Then the final output is correct.

I wonder if there is a more elegant way for this command

Leave a Reply

Your email address will not be published. Required fields are marked *