5

Fun with Bash Double Brackets, Regular Expressions, Case Matching, and Digits

view full story
linux-howto

http://www.humans-enabled.com – After some quick searching and not finding the answer, I decided to write this up for my own reference.My original inquiry was how do I form a double-bracketed if branch statement, using "=~" to check a variable against a regular expression for upper OR lower case of a specific search string in bash. After some working it out, I think I got it. See below.For instance, in the example script below, the user is asked to answer yes or no, the value entered is then checked to "loosely" match a predefined value. In this case, yes/y (with any combination of case) will match the Regular Expression.Thi (HowTos)