[SWLUG] si,ple shell in bash not working

Stephen Constantinou stephanos at writeme.com
Fri May 4 10:46:23 UTC 2007


Dear All

I thought I would refresh my script knowledge as I want to write a menu 
in bash.  I will use if's, while and other loops as well as read to take 
in keyboard input.  I made a very modest start and got stumped at the 
very beginning.

I made an executable file called /home/stephanos/ShellScripts/Kaspersky 
and here is the content:
<content starts>
  choice=5
  mid=7
  if [ choice < mid ]
  then
   echo " choice is less than mid"
  else
   echo " choice is greater than mid"
  fi
<content ends>

the output to screen is
   [stephanos at localhost ShellScripts]$ ./Kaspersky
   ./Kaspersky: Line 3: mid: No such file or directory
   choice is greater than mid
   [stephanos at localhost ShellScripts]$

I put a $ at the beginning of choice and mid
    if [ $choice < $mid ]
but the output was similar
   [stephanos at localhost ShellScripts]$ ./Kaspersky
   ./Kaspersky: Line 3: 7: No such file or directory
   choice is greater than mid
   [stephanos at localhost ShellScripts]$

I read a very good online tutorial and I am lost as to what I have done 
wrong.

Any help appreciated

Stephen



More information about the Swlug mailing list