Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

example: command | grep -i bytes

This would only return bytes and not every word that contains bytes like megabytes, kilobytes etc..

Any direction would be appreciated.

share|improve this question
add comment

1 Answer

up vote 6 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
2  
yes, my ability to run "man grep" and search for "word" is, indeed, the stuff of legend =) –  jj33 May 19 '09 at 17:00
add comment

Your Answer

 
discard

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.