How can I match a string with a regex in Bash?

后端 未结 6 1163
囚心锁ツ
囚心锁ツ 2020-12-02 05:04

I am trying to write a bash script that contains a function so when given a .tar, .tar.bz2, .tar.gz etc. file it uses tar with the rel

6条回答
  •  猫巷女王i
    2020-12-02 05:15

    if [[ $STR == *pattern* ]]
    then
        echo "It is the string!"
    else
        echo "It's not him!"
    fi
    

    Works for me! GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)

提交回复
热议问题