harttle.github.io icon indicating copy to clipboard operation
harttle.github.io copied to clipboard

2018/10/23/bash-test

Open utterances-bot opened this issue 6 years ago • 2 comments

Bash 条件判断 | Harttle Land

其实本文不是介绍 条件分支语法 的,只介绍测试(test)语法,也就是说:本文只介绍如何写条件语法中的表达式。其实本文介绍的内容也并未针对 Bash,多数 Shell 都是适用的。与其他编程语言类似,if 的条件可以接受任何 表达式,计算为真就进入分...

https://harttle.land/2018/10/23/bash-test.html

utterances-bot avatar Oct 24 '18 01:10 utterances-bot

大佬高产

Jiavan avatar Oct 24 '18 01:10 Jiavan

耳目一新。

文章中的string1 != string2: 字符串相等 应该是 字符串不相等。

想起了之前看到的这个例子,[[ 语法还是很棒的。

if [ "$ANSWER" = y -o "$ANSWER" = yes ]
if [[ $ANSWER =~ ^y(es)?$ ]]

yantze avatar Nov 05 '18 01:11 yantze