Grep string with regex numeric characters

Hi all,

I have the following entries in a file:

Cause Indicators=80 90
Cause Indicators=80 90
Cause Indicators=82 90
Cause Indicators=82 90
Cause Indicators=82 90
 

The first 2 digits might change so I am after a sort of grep which could find any first 2 digits + the second 2, something similar to:

grep "Cause Indicators='[0-9]' 90 <filename>

The adding of Cause Indicators field in the grep is mostly important since the file contains numerous amounts of numerical characters.

Can this be done via grep?

Thank you!

How about

grep "Cause Indicators=[0-9][0-9] 90" file

Regarding your code sample: You may want to get accustomed to using quotes - be they single or double - in pairs, except for few and rare cases.

1 Like

Hi Rudic,

I'm ashamed, it was so simple. I kept using the single quotes!!

You could have used single quotes or double quotes in your RE, but they have to in matched pairs, and you can't include single quotes inside the double quotes unless you want those single quotes to be treated as literal characters to be matched. The command you showed us had an opening double quote, but no matching closing double quote.