I am trying to check if 2 variables are empty or not defined at the same time in bash. If that is the case, no user password will be changed.
#!/bin/bash
while true
do
read -s -p "Enter root password: " rootpass1
echo
read -s -p "Enter root password again: " rootpass2
echo
if [[-z "$rootpass1"] && [-z "$rootpass2"]]
then
echo "Password will not be changed"
break
else
if [ $rootpass1 != $rootpass2 ]
then
echo "Passwords are not identical"
else
echo "user:$rootpass1" | chpasswd
break
fi
fi
done
But I am getting the following error:
script.sh: line 8: [: missing `]'
Any clue?