spacesearcher
July 19th, 2008, 06:11 AM
ok so i am trying to learn to write bash scripts. I found this page that is helping: http://www.ibm.com/developerworks/library/l-bash2.html
im trying to do the String comparison caveats section. so i write this script
#!/bin/bash
if [ "$myvar" = "foo bar oni" ]
then
echo "yes"
fi
then save it as myscript.sh
in terminal i cd to the directory and do:
joe@joe-laptop:~/Computer practice$ chmod 755 myscript.sh
joe@joe-laptop:~/Computer practice$ myvar="foo bar oni"
joe@joe-laptop:~/Computer practice$ ./myscript.sh
joe@joe-laptop:~/Computer practice$ echo $myvar
foo bar oni
joe@joe-laptop:~/Computer practice$
it never echos yes like it should. >.< this is driving me crazy. all examples have worked but this one hasn't. Am I just not understanding something?
im trying to do the String comparison caveats section. so i write this script
#!/bin/bash
if [ "$myvar" = "foo bar oni" ]
then
echo "yes"
fi
then save it as myscript.sh
in terminal i cd to the directory and do:
joe@joe-laptop:~/Computer practice$ chmod 755 myscript.sh
joe@joe-laptop:~/Computer practice$ myvar="foo bar oni"
joe@joe-laptop:~/Computer practice$ ./myscript.sh
joe@joe-laptop:~/Computer practice$ echo $myvar
foo bar oni
joe@joe-laptop:~/Computer practice$
it never echos yes like it should. >.< this is driving me crazy. all examples have worked but this one hasn't. Am I just not understanding something?