0
oc get serviceinstances | grep -v Ready

There are some results that are "Not Ready" but it would take them out as well because it looks for "Ready".

There are lots of different status names and "Ready" are the only ones I don't need.

For instance:

  1. Ready
  2. Not Ready
  3. Error
  4. Failed

I need "Not Ready", "Error", "Failed"

Tom S
  • 511
  • 4
  • 18

5 Answers5

0

Using your example data, you can try the -w flag in conjunction with -v flag

-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 constituent character.
              Word-constituent  characters  are  letters,  digits,   and   the
              underscore.  This option has no effect if -x is also specified.
$ grep -vw ' Ready' input_file

    Not Ready
    Error
    Failed

HatLess
  • 5,048
  • 4
  • 8
  • 28
0

When the fields are separated by tabs, use

oc get serviceinstances | grep -E "\tReady\t"
Walter A
  • 17,923
  • 2
  • 22
  • 40
0

Try

... | gawk '/\s+Not Ready\s+/ || !/\s+Ready\s+/'
konsolebox
  • 66,700
  • 11
  • 93
  • 101
0

oc get serviceinstances | egrep "Not Ready|Error|Failed"

maryf
  • 140
  • 6
0

If your grep supports -P (PCRE support) option, please try:

oc get serviceinstances | grep -v -P "(?<!Not )Ready"

The regex matches Ready unless it is preceded by Not , then the logic is negated by the -v option.

tshiono
  • 17,571
  • 2
  • 13
  • 19