Problem in loops in shell scripting

Hi,

 
#!/bin/ksh
 
$v=""
for ((i = 1 ; i <= 5 ; i++ ))
        do
                v="THerrFile_$i.err";
                grep -i "$i:Error" $v >>oraerror_output.txt
done
 

My requirement is to dynamically create variable like
THerrFile_1.err,THerrFile_2.err etc.

where my grep needs to create 1 file open it each time and apped the grep outout from THerrFile_1.err,THerrFile_2.err,THerrFile_3.err,THerrFile_4.err,THerrFile_5.err

please help.

something like:

#  cat var.ksh 
#!/bin/ksh
 
v=""
for i in 1 2 3 4 5 
        do
                v="THerrFile_$i.err";
                echo $v
done


#  ./var.ksh 
THerrFile_1.err
THerrFile_2.err
THerrFile_3.err
THerrFile_4.err
THerrFile_5.err

should set you in right direction....HTH

i=0
while (( $((i+=1)) < 6 ))
do
echo $i
done

remove $ from $v="" :wink:

hi,

#cat var.ksh
#!/bin/ksh

v=""
for j in 1 2 3 4 5
do
v="THerrFile_$j.err";
grep -i "$j:Error" $v >>oraerr_output$j.txt
done
 

the above code worked
but my requirement in open a single file not 5 files and update the same file.

is it possible.

Thanks...

egrep or grep -e can get a list of patterns.