2

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.

womble
  • 96,255
  • 29
  • 175
  • 230
Nathan Milford
  • 792
  • 2
  • 10
  • 21

1 Answers1

7
   -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.
jj33
  • 11,178
  • 1
  • 37
  • 50