I'm looking to bind to a port for SSH tunnelling via a simple shell script (likely: BASH), and I'd like a more ... "sane" manner of testing whether or not the port is already bound to another process, and I'd rather not like to grok (read: grep) the output of netstat.
Is there some command or utility that makes doing this sane? I either have terrible google-fu and a terrible vocabulary, or most people don't try to iterate over ports programmatically via a shell, but instead via a programming language.