bash - cat not working a pipe -
revised version of question:
cat - | tr "a-z" "a-z" | tr "a-z" "a-z" does not give output when run on bash shell prompt. have press ctrl-d o/p.
o/p
$ cat - | tr "a-z" "a-z" | tr "a-z" "a-z" test however works fine , output without using ctrl-d..why ?
cat - | tr "a-z" "a-z" o/p
$ cat - | tr "a-z" "a-z" test test original version of question:
cat "$@" | tr "a-z" "a-z" | tr "a-z" "a-z" hangs when run on bash shell prompt. why that?
my $@ empty.
however works this
cat "$@" | tr "a-z" "a-z"
what you're seeing due buffering. in
cat - | tr a-z a-z | tr a-z a-z (no quotes needed) may not output after hit enter, because middle or third tr may have buffered data internally. @ point, flush buffers , you'll full, correct output. hitting ctrl-d closes pipe , forces flush.
this typical phenomenon when connecting several commands in 1 pipe.
by way, in this case (but not when using "$@"), cat - superfluous.
Comments
Post a Comment