Using WSL2 (Ubuntu 20.04), I have a file, out.txt
with the phrase password
that I am encoding using base64
:
$ echo password > out.txt
$ base64 out.txt
$ # returns cGFzc3dvcmQ=
I wanted to ask if there was some way to write the output of the base64
command back into its original file out.txt
. When I try to do so currently (base64 out.txt > out.txt
), I end up with a blank file. Piping the command's output into another file (base64 out.txt > oot.txt
) works fine, but I'd prefer if I kept everything to the same file.
Trying to achieve this for the purpose of scripting a shell file with an sshpass command (yes, I know about keyless authentication and whatnot but unfortunately I don't have the ability to configure this on the server I'm connecting to) and would obviously rather not have the password in plaintext in my command history.