simple grep is not working for me

Hi, On the log Netscape log, I need to grep for 500 error. I am doing that but I also get 1500 in that same log.

cat access |grep "500"

Results:
"GET /css/RBR.css HTTP/1.1" 200 15000 304 - - - 399 639 523 164 0

This not what I need... Please advice.

Quote it with a space, like so:

grep " 500 " access

Note: No need to cat into a grep.

Try this

grep -w 500 access
 

Just be careful with this approach. It includes non-word constituents, such as $500 or you might get a number like 159.500.3.24 or something like that.

Of course the down-side to the approach I stated (space sandwich) is if 500 is the first, last or only word of the line, so you need to consider if that's a possiblity. You can get around that like so:

grep -E " 500 |^500 | 500$|^500$" access

Thank you so much to every one, I am able to get my results using grep -w