echo -n 'HelloWorld' | openssl base64 | pbcopyThat command give me a newline after paste it.
I thought the -n removed the newline but don't remove when use base64.
so how can get my output string without a newline?
101 Answer
I'm sure there's simpler ways to do it, but here I'm using awk with output record separator blank. Being there only one record separator, the result will be blank. Now, I can test if there is newline or not by running output to file and cat -A that file to show metacharacters.
$ printf 'Hello World' | openssl base64 | awk 'BEGIN{ORS="";} {print}' > tester.txt
$ cat -A tester.txt
SGVsbG8gV29ybGQ=As you can see, there is no $ sign at the end of that string, hence no new line.
1