You could try something like:
unzip_package="$(rpm -qq unzip)"
if [[ $unzip_package =~ ^unzip.*$ ]]; then
# ... run command
else
echo "Unzip is not installed."
fi
Here's a few comments on your code:
1) To run a command in subshell and catch the output in a variable, there's two syntax :
var="$(command)"
var=`command`
But not:
var='command'
2) You need space inside brackets in your test:
[ -z "$unzip" ]
: [
is an alias of the test
command (or a builtin in bash with same behavior). You should also protect your operands with douple quotes when you use this syntax.
[[ -z $unzip ]]
: available since KSH88 (in my memory) and allow more powerfull stuffs like testing regexp since bash 4+ with the =~
operator.
You should see this reminder to get more details.
3) You miss a fi
to close the if
statement
4) Be careful with the case of statements: if
and not If
5) You also miss multiples semicolons:
if <cmd1>; then <cmd2>; else <cmd3>; fi
Or:
if ...; then
# do some stufs
else
# ...
fi
Or:
if ....
then
# do some stufs
else
# ...
fi
To conclude you really should learn a little bit more the basics of shell syntax and statements. Here's a really good guide for Bash.