You are not logged in.
I want to add an if statement to one of my scripts to check the architecture of the computer but I cant seem to get the formatting of the if statement right. heres what I have so far:
arch=`uname -m`
if [[ "$arch" == 'x86_64']]
then
echo "x86_64"
else
echo "i686"
fi
Last edited by brando56894 (2009-05-16 05:21:56)
Offline
Look in the kernel PKGBUILD, if I'm correct it should have such a check already.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
if [ "$arch" == "x86_64" ]
Offline
arch=`uname -m`
if [ "$arch" == "x86_64" ]
then
echo "x86_64"
else
echo "i686"
fi
Note only one "[" and spaces after "[" and before "]" and the consistent use of quotes.
or in one line...
[ "$arch" == "x86_64" ] && echo "x86_64" || echo "i686"
Offline
#!/bin/bash
arch=$(uname -m)
if [ "$arch" == 'x86_64' ]
then
echo "x86_64"
else
echo "i686"
fi
This works for me.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
sweet thanks guys
Last edited by brando56894 (2009-05-16 05:21:42)
Offline
Couldn't you do:
echo $(uname -m)
?
Offline
I'm guessing he wants to do something more complicated than the "echo" at some stage...
Offline
You are correct. What I posted was just a simple statement test. I'm actually using it in my stage 2 installation script to select the proper pacman source files depending on whether its a 32 bit or 64 bit system.
Offline
Offline