grep -v "^[11,12d9]"
yes, as you found out -v
is used for invert match and will return lines that do not match the given pattern ^[11,12d9]
.
and what ^[11,12d9]
is doing is that saying match characters in [...]
and if they were appeared at the begging of a line (^
is the beginning of the line anchor) then ignore those lines (since of used -v
invert match);
so basically lines that started with one of 1
, ,
, 2
, d
or9
characters will be ignored (repeated characters also will be ignored within character-class).
but if you would like to ignore the line starting with string 11,12d9
, you need grep -v '^11,12d9'
.
*Not relevant to the question but to keep notes about use of ]
, ^
and -
characters within character class:
if ^
character: it can be placed anywhere in []
but not the first character; if it was first character, it acts as negation on the characters within that class.
if ]
character: it should be the first character.
if -
character: it should be the last character.
-v
is not reverse search (it does not read the file/stream backwards). It is a inverted filter (find those that don't match).