for((i=1;i<=10;i++));
do
echo $i
done
echo "end of 1st loop"
for i in {20..30}
do
echo $i
done
echo "end of 2nd loop"
i=40
while [ $i -le 50 ]
do
echo $i
let i=i+1
done
echo "end of 3rd loop"
============================================
seq 1 100
====================================
# print 1 to 100
for i in `seq 1 100`; do echo $i; done
==========================
# display 1 to 10 numbers using while loop
# vi while.sh
# !.bin/sh
a=1
while [[ $a -le 10 ]]
do
echo “$a”
a= ` expr a + 1 ` or let a=a+1
done
===============================================
HowTo: Unix For Loop 1 to 100 Numbers
January 16, 2010in BASH Shell, KSH Shell, UNIX last updated July 16, 2011
Iwant to run a Unix command 100 times using a for loop from 1 to 100. Can you tell me how to take a block of numbers in a loop under KSH or BASH shell?
You can use the following syntax to run a for loop.
You can use the following syntax to run a for loop.
Ksh For Loop 1 to 100 Numbers
Bash For Loop 1 to 100 Numbers
Dealing With Older KSH88 or Bash shell
The above KSH and Bash syntax will not work on older ksh version running on HP-UX or AIX. Use the following portable syntax:
No comments:
Post a Comment