I know that running
cat with no argument reflects the user input
$ cat test test reflected reflected
I want to pipe the reflected output to another program such as
base64. The expected behavior is like so
$ cat | base64 test dGVzdA== another YW5vdGhlcg==
I want this for encoding text line-by-line as I type, and/or send them over something like
nc. However, when used like this, no output seems to be reflected and escaping with
ctrl+C just terminates the whole thing without output
$ cat | base64 test fail ^C
With everything working correctly, I should be able to establish an encoded/encrypted connection (very simple chat application) like so
# client $ $CMD | encrypt | nc $SERVER $PORT this is a test multiple lines ^C # host $ nc -lvp | decrypt this is a test multiple lines
Similarly, I should be able to encode & save as follows
$ CMD | base64 | tee log_file test dGVzdA== another YW5vdGhlcg== ^C $ cat log_file dGVzdA== YW5vdGhlcg==
Note that the whole thing should be a single pipe line. Using a loop wouldn't work well as
nc would establish a new connection every iteration and
-a would overwrite the file every line (per iteration). I want 1 single instance of the final command (e.g.
base64) taking input pipe from
CMD like with
cat but with user input instead of a file.
I'm looking for a way to do said piping of user input line-by-line to another process, preferably as a short one-liner. How can I get such piping of user input?