The grep command matches regular expression patterns against lines of input data. Regular expressions are a compact string syntax that can be used to describe patterns in text. They can be simple text strings, such as telnet, which will match any lines that have those six exact letters in sequence:
$ grep 'telnet' /etc/services telnet 23/tcp rtelnet 107/tcp # Remote Telnet rtelnet 107/udp telnets 992/tcp # Telnet over SSL tfido 60177/tcp # fidonet EMSI over telnet
We could use some regular expression properties to filter this data more precisely. For example, to limit the output only to lines that begin with the word telnet, we could use the ^ metacharacter:
$ grep '^telnet' /etc/services telnet 23/tcp telnets 992/tcp # Telnet ...