We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Getting started with conditionals
Getting started with conditionals
Sort by
recency
|
332 Discussions
|
Please Login in order to post a comment
read -p "y" char
if [ "char" == "y" ]; then echo "YES" elif [ "char" == "n" ]; then echo "NO" fi
I used case statement ->
read input case $input in [yY]) echo "YES" ;; [nN]) echo "NO" ;; esac
Easy solution:
EXPLANATION : : we are reading the char, :next if the char == length 1 we pass that to check if it is y,Y,n,N if it is anyone of it we print and exit