[WBEL-users] grep help

Jon Lewis jlewis@lewis.org
Mon, 13 Dec 2004 16:45:01 -0500 (EST)


On Mon, 13 Dec 2004, Timothy Nash wrote:

> Hi all,
>
> I know this is not a WBEL question, but here goes:
>
> If I have a file called "hosts" containing the following:
>
> 10.1.1.2   hostname
> 10.1.1.3   hostname.old
> 10.1.1.4   hostname.mgt
> 10.1.1.5   hostname.
>
> What grep command would I use to search this file for any line that
> contains the whole word "hostname" only? , ie I only want the first line
> returned.
>
> I thought the following would work:
>
> grep 'hostname$' hosts
>
> but this returns nothing.

You probably have some stray spaces at the end of the first line.  That
grep does work as expected for me, both on a fedora core 2 system and a
WBEL (Liberation Respin 1) system.

----------------------------------------------------------------------
 Jon Lewis                   |  I route
 Senior Network Engineer     |  therefore you are
 Atlantic Net                |
_________ http://www.lewis.org/~jlewis/pgp for PGP public key_________