The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 12-25-2007
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
Quote:
Originally Posted by mrityunjay22 View Post
code is as

#!/bin/sh

i=1;
while [ $i -le 5]
do
welcome $i times;

i='expr $i+1';


done
exit 0;
The while test expression should have proper spacing as well as the line that increments i. Don't need the terminating semicolons after every command. Is welcome as in "welcome $i times" a functon in your script and it would be nice to printout the value of i while executing the loop...

Code:
#!/bin/sh

i=1
while [ $i -le 5 ]
do
   welcome $i times;
   echo "value of i is...$i"
   i='expr $i + 1'
done
exit 0