Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am grepping the output of a command and I wish to only return specific, strict results.

I remember some iteration of grep had a strict option -s/--strict.

For example, grep -s bytes would only return entries which mentioned the word "bytes" and not every word that contains bytes, like "megabytes", "kilobytes", etc.

share|improve this question
up vote 7 down vote accepted
   -w, --word-regexp
          Select  only those lines containing matches that form whole
          words.  The test is that the matching
          substring must either be at the beginning of the line, or 
          preceded  by  a  non-word  constituent
          character.   Similarly,  it  must be either at the end of the
          line or followed by a non-word con-
          stituent character.  Word-constituent characters are
          letters, digits, and the underscore.
share|improve this answer
Fantastic, sir. I salute you and your thorough grep knowledge. :) – Nathan Milford May 19 '09 at 15:59
yes, my ability to run "man grep" and search for "word" is, indeed, the stuff of legend =) – jj33 May 19 '09 at 17:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.