If you don't mind building up a hash into memory every time you run it, and you don't mind not only having to hardcode the service, but also having to use the form '21/tcp' instead of '21tcp', then the following code should do the job:
But then again, it looks like i just reinvented a wheel called 'grep'. ;)perl -lane'$h{$F[1]}=$F[0]}{print $h{"21/tcp"}' /etc/services
I would be surprised if there is not an existing CPAN module for this task ... i don't know of one off hand ...
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: Service: port to name
by jeffa
in thread Service: port to name
by carric
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |