sar*_*eed 2 command-line shell-script
遇到一个在条件中包含 '=~' 的 shell 脚本,我想知道它是什么意思。在 Google 或 SO 网站上运气不佳。
例子:
if [[ $VAR =~ 'this string' ]]
Run Code Online (Sandbox Code Playgroud)
这是一个正则表达式匹配运算符。
从bash手册页:
An additional binary operator, =~, is available, with the same
precedence as == and !=. When it is used, the string to the
right of the operator is considered an extended regular
expression and matched accordingly (as in regex(3)). The return
value is 0 if the string matches the pattern, and 1 otherwise.
Run Code Online (Sandbox Code Playgroud)
有关bash更多详细信息,请参阅的手册页(搜索=~)
| 归档时间: |
|
| 查看次数: |
15273 次 |
| 最近记录: |