1
I've figured out why cat | base64 doesn't work as I intended. base64 needs to take in all of the input, terminated by (I think) an EOF. Since output from cat doesn't have the terminator, base64 never stopped taking in and buffering the input, and ctrl-C terminates both cat and base64. Basically, base64 is waiting for the output from cat to end with EOF but ...
1
Something like this?
# this is an infinite loop, but can be changed to whatever you need
while true; do read x; echo "$x" | base64; done
Output:
foo
Zm9vCg==
bar
YmFyCg==
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
pipe × 1552bash × 452
shell × 289
shell-script × 182
io-redirection × 171
command-line × 113
grep × 107
linux × 102
fifo × 90
stdin × 70
stdout × 60
xargs × 59
tee × 57
find × 55
awk × 50
sed × 45
text-processing × 43
cat × 42
files × 39
tail × 38
process-substitution × 37
tar × 35
ssh × 34
process × 34
scripting × 31