I must be overlooking something, but I don't understand why this doesn't work. I'm trying to grep on a date, excluding all the lines starting with a dash:
testfile:
#2013-12-31
2013-12-31
code:
grep '^[^#]2013-12-31' testfile
I'm expecting to see just the second line '2013-12-31' but I don't get any results. grep -v is not an option btw.
Elementary. [^#] will match one character which is not an octothorpe (or hash). So, what you are asking grep to match is one non-hash character (mandatory for the overall pattern to match) at the beginning of a line followed by 2013-12-31 .