I can use Bash to match a character set
$ [[ a =~ [abc] ]]; echo $? 0
However, if I want a square bracket to be included in the set ] , it fails
]
$ [[ a =~ [abc\]] ]]; echo $? 1 $ [[ a =~ [abc\\]] ]]; echo $? 1
On the man regex(7) page:
regex(7)
To include a literal ']' in the list, make it the first character (fol- lowing a possible '^').
Testing:
$ [[ "]" =~ []abc] ]]; echo $? 0