Posts

Showing posts from January 16, 2019

elif condition in an if statement

Image
up vote 1 down vote favorite I have this variables start=$1; end=$2; sn=${#start} en=${#end} and this if : if ( [ $# -eq 2 ] ) then elif ( [ $sn -ne 3 ] && [ -n "$(printf '%sn' "$start" | sed 's/[0-9]//g') " ] ); then echo "Incorrect format" exit 1 elif ( [ $en -ne 3 ] && [ -n "$(printf '%sn' "$end" | sed 's/[0-9]//g') " ] ); then echo "Incorrect format" exit 1 else echo "Correct format" exit 1 fi and I get unexpected at the first elif , I want to check the arguments provided by the user and they have to be made by only 3 digits . bash sed scripting variable