Advertisement
starfry

Feedback for http://unix.stackexchange.com/a/218689

Jul 28th, 2015
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. Example 1:
  2.  
  3. $ cat /tmp/test | tr '<\n' '\n<' | paste -sd\\n - - | sed -e'/^[0-9]\{1,\}>/!{$!H;1h;$!d' -e\} -e'x;y/\n</<\n/;s//<&/'
  4.  
  5. works as expected. Output:
  6.  
  7. <37> Jul 28 10:40:47 127.0.0.1 time="2015-07-28 10:40:47" msg="LOGOUT User admin logged out on TELNET (10.0.200.1)"
  8. <37> Jul 28 10:45:58 127.0.0.1 time="2015-07-28 10:45:58" msg="LOGIN User admin logged in on TELNET (10.0.200.1)"
  9. <37> Jul 28 10:40:47 127.0.0.1 time="2015-07-28 10:40:47" msg="LOGOUT User admin logged out on TELNET (10.0.200.1)"
  10. <37> Jul 28 10:45:58 127.0.0.1 time="2015-07-28 10:45:58" msg="LOGIN User admin logged in on TELNET (10.0.200.1)"
  11.  
  12. Example 2:
  13.  
  14. In terminal A
  15.  
  16. $ socat -u UDP-RECV:4321 STDOUT | tr '<\n' '\n<' | paste -sd\\n - - | sed -e'/^[0-9]\{1,\}>/!{$!H;1h;$!d' -e\} -e'x;y/\n</<\n/;s//<&/'
  17.  
  18. In terminal B
  19.  
  20. $ cat /tmp/test | netcat -u localhost 4321
  21.  
  22. Expected output in terminal A, got nothing. Running just "socat -u UDP-RECV:4321 STDOUT" in terminal A gets output so it isn't a comms issue.
  23.  
  24. (intentional uuoc in the examples to express the syle of pipeline being used)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement