How do I prompt for Yes/No/Cancel input in a Linux shell script?

后端 未结 30 2048
不思量自难忘°
不思量自难忘° 2020-11-22 04:52

I want to pause input in a shell script, and prompt the user for choices.
The standard Yes, No, or Cancel type question.
How d

30条回答
  •  自闭症患者
    2020-11-22 05:26

    Use the read command:

    echo Would you like to install? "(Y or N)"
    
    read x
    
    # now check if $x is "y"
    if [ "$x" = "y" ]; then
        # do something here!
    fi
    

    and then all of the other stuff you need

提交回复
热议问题