bash - Regex square close bracket -


i can use bash match set of characters

$ [[ =~ [abc] ]]; echo $? 0 

however if want close square bracket ] included in set, fails

$ [[ =~ [abc\]] ]]; echo $? 1  $ [[ =~ [abc\\]] ]]; echo $? 1 

from man page regex(7):

to include literal ']' in list, make first character (fol- lowing possible '^').   

testing:

$ [[ "]" =~ []abc] ]]; echo $? 0 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -