there is one line in file data, as
[overall], ….
when using grep to obtain this line, I find this can be done only by
grep “\[overall]” data
just out of curiosity, Why does it need to escape [ while not for ].
EDIT: this is tested on ubuntu 12.04
Because the
]only has any special meaning when it has already been preceded by a[that was not escaped.You can have fun (if you’ve got the right, somewhat distorted, mindset) with:
This searches for
],[or-. You have to be careful with the placement of]; it must go at the start of the character class. You have to be careful with the placement of-; it must go at the start or end of the class. And the caret that negates a class must go first.