Bash command to list open ports in macOS

Bash command to list open ports in macOS

sudo lsof -PiTCP -sTCP:LISTEN

will get an answer like this

..
Dropbox   684 user   82u  IPv4 0xXXXX   0t0  TCP *:17500 (LISTEN)
Dropbox   684 user   83u  IPv6 0xXXXX   0t0  TCP *:17500 (LISTEN)
Dropbox   684 user  122u  IPv4 0xXXXX   0t0  TCP localhost:17600 (LISTEN)
Dropbox   684 user  125u  IPv4 0xXXXX   0t0  TCP localhost:17603 (LISTEN)
...