2007-09-12, 10:00(-07), chitti: > > I need to seperate the UDP and TCP ports from the /etc/services files. > any pointers or help on scripting this in bash would be helpful > thanks
awk '
NF == 0 || $1 ~ /^#/ {next}
$2 ~ /\/tcp$/ {print > "services.tcp"; next}
$2 ~ /\/udp$/ {print > "services.udp"; next}
{print > "services.other"}' < /etc/services
--
Stéphane
