[WBEL-users] grep help

Timothy Nash tnash1@twcny.rr.com
Mon, 13 Dec 2004 15:28:27 -0500


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.

I then tried:

grep -w 'hostname' hosts

but this returned the first line and the fourth line.

Thanks!  :-)