更新时间:2023-02-21 14:19:39
It was changed between 3.1 and 3.2. Guess the advanced guide needs an update.
这是新的简短描述
功能加入到庆典 - 3.2自
庆典-3.1的释放。和往常一样,
手册(DOC / bash.1)是地方
寻找完整的描述。
This is a terse description of the new features added to bash-3.2 since the release of bash-3.1. As always, the manual page (doc/bash.1) is the place to look for complete descriptions.
剪断
F。引用字符串参数的
[命令的=〜运营商现在的力量
串匹配,与其它模式匹配运算
f. Quoting the string argument to the [[ command's =~ operator now forces string matching, as with the other pattern-matching operators.
不幸的是这将使用脚本,除非你有变量有识之士店模式打破现有的报价,而是直接使用正则表达式中的。下面的例子。
Sadly this'll break existing quote using scripts unless you had the insight to store patterns in variables and use them instead of the regexes directly. Example below.
$ bash --version
GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
$ number=2
$ if [[ $number =~ "[0-9]" ]]; then echo match; fi
$ if [[ $number =~ [0-9] ]]; then echo match; fi
match
$ re="[0-9]"
$ if [[ $number =~ $re ]]; then echo MATCH; fi
MATCH
$ bash --version
GNU bash, version 3.00.0(1)-release (i586-suse-linux)
Copyright (C) 2004 Free Software Foundation, Inc.
$ number=2
$ if [[ $number =~ "[0-9]" ]]; then echo match; fi
match
$ if [[ "$number" =~ [0-9] ]]; then echo match; fi
match