Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Regular Expression in Bash

It is suggested that you use Python script instead of Shell script as much as possible. If you do have to stick with Shell script, you can use =~ for regular expression matching in Bash. This make Bash syntax extremely flexible and powerful. For example, you can match multiple strings using regular expression.

if [[ value =~ ^(v1|v2|v3)$ ]]; then