Chinaunix
标题:
if中如何对 =~ 正则匹配的结果取反 问题
[打印本页]
作者:
xxf19872
时间:
2014-05-04 16:03
标题:
if中如何对 =~ 正则匹配的结果取反 问题
if [[ $ext == 'sql' ]]; then
checkSql=`$SVNLOOK cat -t $TXN $REPOS $name | tr 'A-Z' 'a-z'`
if [[ $checkSql =~ "set names utf8" ]]; then
echo "sql文件必须包含set names utf8"
exit 1
fi
fi
如上代码 如何对第三行的if判断 取反 当不含set names utf8 时候进执行echo语句 求指点
作者:
Herowinter
时间:
2014-05-04 16:36
回复
1#
xxf19872
[[ ! $checkSql =~ "set names utf8" ]]
复制代码
猜的,未测试。
作者:
yestreenstars
时间:
2014-05-04 16:38
本帖最后由 yestreenstars 于 2014-05-04 16:39 编辑
try:
if [[ $checkSql =~ "set names utf8" ]] -> if [[ ! $checkSql =~ "set names utf8" ]]
作者:
xxf19872
时间:
2014-05-04 16:47
谢谢楼上2位 测试成功
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2