Search code examples
bashbinaryxxd

When piping to xxd, why is some text passed through without modification?


netstat  -lntup |grep  3306  
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN 

mysqld is running,the first two lines is a prompt ,you would have to be root to see it all.

netstat  -lntup |grep  3306  |xxd
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
00000000: 7463 7020 2020 2020 2020 2030 2020 2020  tcp        0    
00000010: 2020 3020 3132 372e 302e 302e 313a 3333    0 127.0.0.1:33
00000020: 3036 2020 2020 2020 2020 2020 302e 302e  06          0.0.
00000030: 302e 303a 2a20 2020 2020 2020 2020 2020  0.0:*           
00000040: 2020 2020 4c49 5354 454e 2020 2020 2020      LISTEN      
00000050: 2d20 2020 2020 2020 2020 2020 2020 2020  -               
00000060: 2020 2020 0a  

Why the first two lines can't be shown as in binary format?
Why only tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN shown as in binary format? .


Solution

  • The parenthesized text was written to standard error, not standard output, and so is written directly to the terminal, not the pipe for grep to pass on to xxd.