Im trying to search for a pattern in a file as follows:
SRC_ERROR_CODE=105
SRC_ERROR_CODE=106
...
To achieve this following is the grep statement used:
grep -io "[a-z]*_error_code=[0-9]*" events.log
However i was wondering if instead of using the "*" which fetches 0 to n occurrences of the preceding matched character, the "+" should fetch the same results as well as below:
grep -io "[a-z]+_error_code=[0-9]+" events.log
But, this doesn't seem to work. Could you please guide as to why it doesn't.
Thanks
+will select 1 to N occurrences, and unless specified is greedy in terms of finding matches. I think you need to give more information. Why doesnt it work? Is it returning the wrong set, or is it returning an error, or what?