A couple of friends was asking how to do loop in shell scripts. Here is some simple code.
To loop in DOS:
@set /p start="From:"
@set /p end="To:"
@REM test condition
@IF %start% GTR %end% (GOTO wend)
@REM procedure where condition is "true"
@REM replace with real operations
@REM set new test value
@SET /a start=start+1
This will print the first number to the last number you input on the screen. Replace
@echo %start% with your real operation.
However, DOS script does not handle real numbers. So if I want to loop from 1 to 10, and print the number + 0.5, this will not work. One solution is using Perl. Second, using Linux. Here is the code for Linux.
echo -n "Enter starting code> "
echo -n "Enter ending code> "
for ((i=start; i<=end;i++))
echo "$i+0.1" | bc
If you input 1 and 5, this is print 1.5, 2.5, 3.5, 4.5, 5.5.
Note: I did not create these codes. They are from Google search. However, they are from different sources (especially the use of bc) so I lost the source link.