The difficult part here would be coming up with a generic solution, since what you need from each netstat output would appear to depend on actual human knowledge of which of the listening ports is the 'correct' one. From a technical perspective, they all are: PID 32538 really is listening on ports 7666 and 38970 on all bound IPs, and on port 13804 on the IP 10.2.228.79 specifically.
So aside from you knowing which of these is the one you want, you'd need some way of identifying something that the ports you're after will actually always have in common, if you want a generic scriptable run-one-command-and-get-the-answer solution. Is there something you would always look for or which would be scriptably identifiable as the signifier of which port was the 'correct' one ? If so, then if you can give a bit more detail we may be able to narrow this down further.
As for the fd command - I've never heard of that one, sorry. Doesn't seem to either be installed or to be an option for installation on any Linux or Solaris system I currently have access to.
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Thanks Given: 260
Thanked 420 Times in 361 Posts
Originally Posted by drysdalk
... As for the fd command - I've never heard of that one, sorry. Doesn't seem to either be installed or to be an option for installation on any Linux or Solaris system I currently have access to.
fd - file & directory maintenance tool
fd [ -abCefhiklmNnPrSsTtuvx ] [ -NAME=value ] [ directory [ directory2
fdsh [ -abCcefhiklmNnPrSsTtuvx ] [ args ]
Fd is a file & directory maintenance tool considered for the text ter-
minals on general UNIX. It aims for a clone of the same named utility
which is made for the PC/AT compatible machine and PC-9800 series. In
fact, it is upper compatible functionally.
See Debian package fdclone:
fd file & directory maintenance tool (man)
Path : /usr/bin/fd
Version : - ( /usr/bin/fd, 2014-08-03 )
Type : ELF 64-bit LSB executable, x86-64, version 1 (SYSV ...)
Help : probably available with -h