bash user input if

前端 未结 5 1146
没有蜡笔的小新
没有蜡笔的小新 2020-12-25 12:54

I am tring to do simple

Do you want to do that? [Y,n] _

question in bash.

i tried

echo \"Do that? [Y,n]\"
read DO_T         


        
5条回答
  •  醉话见心
    2020-12-25 13:12

    You can use case modification operator:

    if [ "${DECISION^^}" = "Y" ]; then
    ...
    fi
    

    You can find more in bash manual under "Parameter Expansion".

提交回复
热议问题