[WBEL-users] grep help

Timothy Nash tnash1@twcny.rr.com
Tue, 14 Dec 2004 11:24:11 -0500


This is a multi-part message in MIME format.
--------------030504040105020302090308
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Jon Lewis wrote:

>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_________
>_______________________________________________
>Whitebox-users mailing list
>Whitebox-users@beau.org
>http://beau.org/mailman/listinfo/whitebox-users
>
>  
>
It works for me on my linux box as well.  A friend of mine asked me this 
question - not sure exactly what he's trying to do.  I just found out 
he's using Solaris.  Anyone know why Solaris treats periods differently 
than  Linux.  When he issues any of the following commands:

grep -w "hostname" hosts
grep -w 'hostname' hosts
grep -w hostname hosts

the following is output:

10.1.1.2    hostname
10.1.1.5    hostname.

--------------030504040105020302090308
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Jon Lewis wrote:
<blockquote cite="midPine.LNX.4.58.0412131642590.1452@web1.mmaero.com"
 type="cite">
  <pre wrap="">On Mon, 13 Dec 2004, Timothy Nash wrote:

  </pre>
  <blockquote type="cite">
    <pre wrap="">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.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
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                |
_________ <a class="moz-txt-link-freetext" href="http://www.lewis.org/~jlewis/pgp">http://www.lewis.org/~jlewis/pgp</a> for PGP public key_________
_______________________________________________
Whitebox-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Whitebox-users@beau.org">Whitebox-users@beau.org</a>
<a class="moz-txt-link-freetext" href="http://beau.org/mailman/listinfo/whitebox-users">http://beau.org/mailman/listinfo/whitebox-users</a>

  </pre>
</blockquote>
It works for me on my linux box as well.&nbsp; A friend of mine asked me
this question - not sure exactly what he's trying to do.&nbsp; I just found
out he's using Solaris.&nbsp; Anyone know why Solaris treats periods
differently than&nbsp; Linux.&nbsp; When he issues any of the following commands:<br>
<br>
grep -w "hostname" hosts<br>
grep -w 'hostname' hosts<br>
grep -w hostname hosts<br>
<br>
the following is output:<br>
<br>
10.1.1.2 &nbsp;&nbsp; hostname<br>
10.1.1.5&nbsp;&nbsp;&nbsp; hostname.<br>
</body>
</html>

--------------030504040105020302090308--