Getting port numbers out of /etc/service

Published: Wednesday, Dec 26, 2007 Last modified: Saturday, Mar 23, 2024

There is usually a couple of ways:

15:14 < hendry> gnychis: tail /etc/services | awk '{print $2}' | awk -F / '{print $1}'

15:18 < m4n> gnychis: while read line; do line="${line%/*}"; echo "${line##* }"; done < yourfile

Though the second one is a bashism.