issue with using -n for string length status« Back to Questions List

I have created a script as part of my task. Here is the code. The issue is:It is not executing the else part when I am not entering any string as an input. So in case I am not entering any string as an input, it shows me the output of non-zero and size is 0. #!/bin/bash #This script is to check string size using -n read -p "please enter any string" strval if [ -n $strval ];then echo "string size is non-zero. Size is ${#strval}" else echo "string size is zero" fi
Posted by emayroy
Asked on November 25, 2018 11:24 am