I am doing some bash script and now I got one variable call source
and one array called samples
, like this:
source='country'
samples=(US Canada Mexico...)
as I want to expand the number of sources (and each source has its own samples) I tried to add some arguments to do this. I tried this:
source=""
samples=("")
if [ $1="country" ]; then
source="country"
samples="US Canada Mexico..."
else
echo "try again"
fi
but when I ran my script source countries.sh country
it didn't work.
What am I doing wrong?
Don't forget about spaces:
source=""
samples=("")
if [ $1 = "country" ]; then
source="country"
samples="US Canada Mexico..."
else
echo "try again"
fi