Skip to main content
2 of 3
added 390 characters in body
Vombat
  • 13.3k
  • 14
  • 47
  • 58

Change your command to this:

nc -zv 192.168.1.1 1-100 2>&1 | grep succeeded

2>&1 causes stderr output of a program to be written to the same file descriptor as stdout. The messages on the terminal are actually mix of error and normal outputs. Without redirecting stderr, pipe will only get stdout hence grep will miss some data.

See section 3.5 here for more info All about redirection.

Vombat
  • 13.3k
  • 14
  • 47
  • 58