1

I found this command at Quick way to find if a port is open on Linux.

exec 6<>/dev/tcp/127.0.0.1/445 || echo "No one is listening!"

I am a newbie to shell scripting. Could anyone please explain me in detail the syntax of this command? Especially exec 6<>/dev/tcp/127.0.0.1/445. Also is exec going to return a bool value or something (since || is being used?)

Thanks a lot.

Community
  • 1
  • 1
aniztar
  • 2,443
  • 4
  • 18
  • 24

1 Answers1

2
<>

does I/O redirection for both reading and writing. See I/O Redirection

The 6 means we assign it to file descriptor six. What are file descriptors?

|| is in bash executed when the lefthand-side command failed. In other words, this in an else

Community
  • 1
  • 1
timbru31
  • 365
  • 2
  • 21