zvtral
1
dear all,
i have code shell like this but i want to using parameter for this shell how i can do that :
ex ./sample.sh 100 500
sample.sh
START=${1}
LAST=${2}
for (( a=${START}; a<=${LAST}; a++ ))
do
{
echo $a
}
done
thx for your advice
for-loop in C-style aren't posix standard. Try one of the following options:
for i in {100..500}
do
echo $a
done
a=100
while [ $a -le 500 ]
do
echo $a
a=$(($a + 1))
done
zvtral
3
@balajsuri thx for your replay but i dont want using insert variable in scrpit but using parameter for inserting like my example:)
a=$1
while [ $a -le $2 ]
do
echo $a
a=$(($a + 1))
done
If you insist on using C-style for loops, here's an example:
for (( i=$1; i<=$2; i++ ))
do
echo $i
done
zvtral
5
good... whats difference if using while read line and while only iam stillnot understand with this difference
while read <var_name>
--> read contents from a file line by line. For e.g. you have a file input.dat with following contents:
AAAA
BBBB
CCCC
The following while loop will read the file line by line and echo it:
while read x
do
echo $x
done < input.dat