Getting started with conditionals

Sort by

recency

|

333 Discussions

|

  • + 0 comments

    read input

    if [[ input == 'y' ]]; then echo "YES" elif [[ input == 'n' ]];then echo "NO" fi

  • + 0 comments

    read -p "y" char

    if [ "char" == "y" ]; then echo "YES" elif [ "char" == "n" ]; then echo "NO" fi

  • + 0 comments
    read x
    
    case $x in
        y|Y) echo "YES" ;;
        n|N) echo "NO" ;;
    esac
    
  • + 0 comments
    read input
    if [[ $input == "y" || $input == "Y" ]]
    then
    echo "YES"
    else
    echo "NO"
    fi
    
  • + 0 comments

    I used case statement ->

    read input case $input in [yY]) echo "YES" ;; [nN]) echo "NO" ;; esac