Place the ]
immediately after the ^
.
Here's an example. Input file "foo" contains:
foo
[
bar
]
baz
quux
We execute the command:
grep '[^][]' foo
The output is:
foo
bar
baz
quux
From the documentation on bracket expressions in POSIX regular expressions:
The right-bracket ( ']' ) shall lose its special meaning and represent itself in a bracket expression if it occurs first in the list (after an initial circumflex ( '^' ), if any).
and also:
The special characters '.', '*', '[', and '\' (period, asterisk, left-bracket, and backslash, respectively) shall lose their special meaning within a bracket expression.