How to grep regex1 OR regex2?

ehr*_*ehr 0 regex bash grep

I would like to grep (on ubuntu18.04) a every line that fits the pattern that "at least one of two number is greater than 0".

I found infomation about '|' usage in regex but I see it does not work here.

One of tried option:

grep -E "Foo:[1-9]+ | Bar:[1-9]+" input
Run Code Online (Sandbox Code Playgroud)

which returns:

grep -E "Foo:[1-9]+ | Bar:[1-9]+" input
Run Code Online (Sandbox Code Playgroud)

and that is invalid cause it matches only Bar:[1-9]+

Input data:

Foo:1, Bar:1
Foo:0, Bar:1
Run Code Online (Sandbox Code Playgroud)

Expected result in a solution:

Foo:1, Bar:0
Foo:1, Bar:1
Foo:0, Bar:1
Foo:0, Bar:0
Foo:55, Bar:0
Run Code Online (Sandbox Code Playgroud)

cho*_*oba 6

问题是数字后面的空格:您的输入数据中没有这样的空格。

grep -E 'Foo:[1-9]|Bar:[1-9]'
Run Code Online (Sandbox Code Playgroud)

给出预期的输出。

可以进一步简化为

grep -E '(Foo|Bar):[1-9]'
Run Code Online (Sandbox Code Playgroud)

请注意,+不需要:以1-9开头的数字已经大于0,即使它后面跟着0或什么也没有。