Getting port numbers out of /etc/service

Published: Wednesday, Dec 26, 2007 Last modified: Wednesday, Dec 2, 2020

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.