Bash regex =~ operator

前端 未结 2 1747

What is the operator =~ called? Is it only used to compare the right side against the left side?

Why are double square brackets required when running a

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 03:29

    1. What is the operator =~ called?

      I'm not sure it has a name. The bash documentation just calls it the =~ operator.

    2. Is it only used to compare the right side against the left side?

      The right side is considered an extended regular expression. If the left side matches, the operator returns 0, and 1 otherwise.

    3. Why are double square brackets required when running a test?

      Because =~ is an operator of the [[ expression ]] compound command.

提交回复
热议问题