I am grepping date 2019-09-XX
and 2019-10-XX
but somehow my grep not helping out, i am sure i am missing something here
Last Password Change: 2019-10-30
Last Password Change: 2017-02-07
Last Password Change: 2019-10-29
Last Password Change: 2019-11-03
Last Password Change: 2019-10-31
Last Password Change: 2018-09-27
Last Password Change: 2018-09-27
Last Password Change: 2019-06-27
I am doing following and it doesn't work
grep "2019\-[09,10]\-" file
also tried grep "2019\-{09,10}\-" file
[]
matches one character of those it has inside, so your first regex would match2019-,-
for example.{}
determines how many characters must be matched for the previous matching atom, in your case-
, so your second regex would match2019-----------
. That's in extended regular expressions, though. Since you didn't supply-E
or-P
, then{}
doesn't have special meaning. So, it matches literally2019-{09,10}-
. – JoL Nov 14 '19 at 01:41