bash string compare to multiple correct values

前端 未结 5 979
时光取名叫无心
时光取名叫无心 2020-12-01 02:41

i have the following piece of bashscript:

function get_cms {
    echo \"input cms name\"
    read cms
    cms=${cms,,}
    if [ \"$cms\" != \"wordpress\" &am         


        
5条回答
  •  难免孤独
    2020-12-01 03:14

    Instead of saying:

    if [ "$cms" != "wordpress" && "$cms" != "meganto" && "$cms" != "typo3" ]; then
    

    say:

    if [[ "$cms" != "wordpress" && "$cms" != "meganto" && "$cms" != "typo3" ]]; then
    

    You might also want to refer to Conditional Constructs.

提交回复
热议问题