Today I found myself in a situation where I needed to know if container was listening to a port. I didn’t have sudo, ss or deprecated netstat available.

Luckily, I found a handy oneliner that I will copy here for my future needs.

declare -a array=($(tail -n +2 /proc/net/tcp | cut -d":" -f"3"|cut -d" " -f"1")) && for port in ${array[@]}; do echo $((0x$port)); done