How to use grep with alternating part of the regular expression?

152 Views Asked by At

I want to grep all dates in August or September (date format mm/dd/yyyy with leading zeroes).

I tried:

grep '0\(8\|9\)/[0-9][0-9]/2012'

But command prompt outputs:

The system cannot find the path specified.

1

There are 1 best solutions below

1
On BEST ANSWER

grep wants a regular expression and a file name. The error message looks like you somehow passed an invalid file name. Assuming the file containing the log entries is named log, try this;

grep '0[89]/[0-9][0-9]/2012' log

(I also tweaked your regex a bit.)