You can reverse the meaning of the square brackets by putting a ^
immediately after the [
. In this case, the brackets will match any character
that is not listed inside the brackets. Again, note that we use [^]
with regular expressions, but [!]
with globs:
$ grep dev.hda[^12] /etc/fstab
/dev/hda3 / reiserfs noatime,ro 1 1
#/dev/hda4 /mnt/extra reiserfs noatime,rw 1 1