How to compare strings in Bash

前端 未结 10 1856
眼角桃花
眼角桃花 2020-11-22 02:48

How do I compare a variable to a string (and do something if they match)?

10条回答
  •  执笔经年
    2020-11-22 03:22

    To compare strings with wildcards use

    if [[ "$stringA" == *$stringB* ]]; then
      # Do something here
    else
      # Do Something here
    fi
    

提交回复
热议问题