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:
- Ready
- Not Ready
- Error
- Failed
I need "Not Ready", "Error", "Failed"
CodePudding user response:
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
CodePudding user response:
When the fields are separated by tabs, use
oc get serviceinstances | grep -E "\tReady\t"
CodePudding user response:
Try
... | gawk '/\s Not Ready\s / || !/\s Ready\s /'
CodePudding user response:
oc get serviceinstances | egrep "Not Ready|Error|Failed"
CodePudding user response:
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.
