Skip to main content
Spelling in title and other smaller fixes; edited tags
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Getting an error in the if condttioncondition

I am just checking whether the password contains a small and capital case letter, I am getting an error at line 19.

myscript.sh

myscript.sh:

#!bin/sh

read password
conditionarr=(0 0)

if [[ $password =~ [A-Z] ]]
then
   condtionarr[1]=1
fi


if [[ $password =~ [a-z] ]]
then
   conditionarr[0]=1
fi


if [ ${conditionarr[0]} == 1 || ${conditionarr[1]} == 1 ]
then
    printf "%s" "Yes\n "
else
    printf "%s" "No\n"
fi

error

The error:

./myscript.sh: line 19: [: missing `]'

./myscript.sh: line 19: 0: command not found

What is wrong inwith this code  ? Can anyone tell me how to fix this?

Getting an error in the if condttion

I am just checking whether the password contains a small and capital case letter, I am getting an error at line 19.

myscript.sh

#!bin/sh

read password
conditionarr=(0 0)

if [[ $password =~ [A-Z] ]]
then
   condtionarr[1]=1
fi


if [[ $password =~ [a-z] ]]
then
   conditionarr[0]=1
fi


if [ ${conditionarr[0]} == 1 || ${conditionarr[1]} == 1 ]
then
    printf "%s" "Yes\n "
else
    printf "%s" "No\n"
fi

error

./myscript.sh: line 19: [: missing `]'

./myscript.sh: line 19: 0: command not found

What is wrong in this code  ? Can anyone tell how to fix this?

Getting an error in the if condition

I am just checking whether the password contains a small and capital case letter, I am getting an error at line 19.

myscript.sh:

#!bin/sh

read password
conditionarr=(0 0)

if [[ $password =~ [A-Z] ]]
then
   condtionarr[1]=1
fi


if [[ $password =~ [a-z] ]]
then
   conditionarr[0]=1
fi


if [ ${conditionarr[0]} == 1 || ${conditionarr[1]} == 1 ]
then
    printf "%s" "Yes\n "
else
    printf "%s" "No\n"
fi

The error:

./myscript.sh: line 19: [: missing `]'

./myscript.sh: line 19: 0: command not found

What is wrong with this code? Can anyone tell me how to fix this?

deleted 2 characters in body
Source Link

I am just checking whether the password contains a small and capital case letter, I am getting an error at line 19.

myscript.sh

#!bin/sh

read password
condition_arr=conditionarr=(0 0)

if [[ $password =~ [A-Z] ]]
then
   condtion_arr[1]=1condtionarr[1]=1
fi


if [[ $password =~ [a-z] ]]
then
   conditionarr[0]=1
fi


if [ ${conditionarr[0]} == 1 || ${conditionarr[1]} == 1 ]
then
    printf "%s" "Yes\n "
else
    printf "%s" "No\n"
fi

error

./myscript.sh: line 19: [: missing `]'

./myscript.sh: line 19: 0: command not found

What is wrong in this code ? Can anyone tell how to fix this?

I am just checking whether the password contains a small and capital case letter, I am getting an error at line 19.

myscript.sh

#!bin/sh

read password
condition_arr=(0 0)

if [[ $password =~ [A-Z] ]]
then
   condtion_arr[1]=1
fi


if [[ $password =~ [a-z] ]]
then
   conditionarr[0]=1
fi


if [ ${conditionarr[0]} == 1 || ${conditionarr[1]} == 1 ]
then
    printf "%s" "Yes\n "
else
    printf "%s" "No\n"
fi

error

./myscript.sh: line 19: [: missing `]'

./myscript.sh: line 19: 0: command not found

What is wrong in this code ? Can anyone tell how to fix this?

I am just checking whether the password contains a small and capital case letter, I am getting an error at line 19.

myscript.sh

#!bin/sh

read password
conditionarr=(0 0)

if [[ $password =~ [A-Z] ]]
then
   condtionarr[1]=1
fi


if [[ $password =~ [a-z] ]]
then
   conditionarr[0]=1
fi


if [ ${conditionarr[0]} == 1 || ${conditionarr[1]} == 1 ]
then
    printf "%s" "Yes\n "
else
    printf "%s" "No\n"
fi

error

./myscript.sh: line 19: [: missing `]'

./myscript.sh: line 19: 0: command not found

What is wrong in this code ? Can anyone tell how to fix this?

added 4 characters in body
Source Link

I am just checking whether the password contains a small and capital case letter, I am getting an error at line 19.

myscript.sh

#!bin/sh

read password
condition_arr=(0 0)

if [[ $password =~ [A-Z] ]]
then
   condtion_arr[1]=1
fi 


if [[ $password =~ [a-z] ]]
then
   conditionarr[0]=1
fi 


if [ ${conditionarr[0]} == 1 || ${conditionarr[1]} == 1 ]
then
    printf "%s" "Yes\n "
else
    printf "%s" "No\n"
fi

error

./myscript.sh: line 19: [: missing `]'

./myscript.sh: line 19: 0: command not found

What is wrong in this code ? Can anyone tell how to fix this?

I am just checking whether the password contains a small and capital case letter, I am getting an error at line 19.

myscript.sh

#!bin/sh

read password
condition_arr=(0 0)

if [[ $password =~ [A-Z] ]]
then
   condtion_arr[1]=1
fi

if [[ $password =~ [a-z] ]]
then
   conditionarr[0]=1
fi

if [ ${conditionarr[0]} == 1 || ${conditionarr[1]} == 1 ]
then
    printf "%s" "Yes\n "
else
    printf "%s" "No\n"
fi

error

./myscript.sh: line 19: [: missing `]'

./myscript.sh: line 19: 0: command not found

What is wrong in this code ? Can anyone tell how to fix this?

I am just checking whether the password contains a small and capital case letter, I am getting an error at line 19.

myscript.sh

#!bin/sh

read password
condition_arr=(0 0)

if [[ $password =~ [A-Z] ]]
then
   condtion_arr[1]=1
fi 


if [[ $password =~ [a-z] ]]
then
   conditionarr[0]=1
fi 


if [ ${conditionarr[0]} == 1 || ${conditionarr[1]} == 1 ]
then
    printf "%s" "Yes\n "
else
    printf "%s" "No\n"
fi

error

./myscript.sh: line 19: [: missing `]'

./myscript.sh: line 19: 0: command not found

What is wrong in this code ? Can anyone tell how to fix this?

Source Link
Loading