This:
arch = `getconf LONG_BIT`
should be:
arch=`getconf LONG_BIT`
or better:
arch=$(getconf LONG_BIT)
You can't use spaces around assignments in bash
. What you wrote executed a command called arch
with arguments =
and the output from getconf LONG_BIT
(presumably 32 or 64).
You also need to keep command names (such as [[
) separate from the arguments, in general. So, you need to change this:
if [[$os = 'CentOs' && $version >= '6.0' && $arch = '64']]
so it has spaces around the 'command' name (after the [[
and before the ]]
):
if [[ $os = 'CentOs' && $version >= '6.0' && $arch = '64' ]]
I'd probably enclose the variables in double quotes, but it isn't 100% necessary. Then there's the problem that [[
does not support the <=
or >=
operators (anyone know why not?). So, you have to use negated logic:
if [[ $os = 'CentOs' && ! ($version < '6.0') && $arch = '64' ]]
Be careful. Attach the !
to the ($version < '6.0')
and you get 'event not found' (if I wanted a sea shell, I'd go to the sea shore; I wish they'd leave historical C shell notations out of bash
).
os=$(lsb_release -si)
version=$(lsb_release -sr)
arch=$(getconf LONG_BIT)
if [[ $os = 'CentOs' && ! ($version < '6.0') && $arch = '64' ]]
then
echo "Works fine"
echo "Version $version; OS $os; Arch $arch"
fi