# this line should output ssh banner nc localhost 22 # this line should output the same string expect the replacements nc localhost 22|sed 's/SSH/XXX/g' nc localhost 22 > foo # after killing the process, I can see the banner in file `foo` nc localhost 22|sed 's/SSH/XXX/g' > foo # however I see nothing when sed is used
as mentioned, if I use
sed to pipe the
nc's output, the
sed's output can't be redirected to a file.
And I also tried other commands to pipe the result, like
tr, the same result.
cat can pipe the result to a file. strange..
nc localhost 22|cat > foo
So why this happen? what is the difference between
cat and other commands in this situation? how can I make
sed's output redirect to file like