I have a loop running until a variable L that is read previously in the full script. I'd like to grep some information in an input file at a line that contains the value of the loop parameter $i.
I've tried to use grep, but the problem is nothing is written in the FILE files. It seems grep cannot find "$i".
(I've tried to avoid awk to keep the sed etc I'm using after.)
Any idea?
Thanks in advance!
#!/bin/bash
L=5
INPUT=input
for i in $(eval echo {0..$L})
do
FILE=File$i.dat
test -e $FILE || touch $FILE
grep "#stuff 1 1 $i stuff_i_want_to_get" $INPUT | sed "y/(),/ /" | cut -d' ' -f6- >> $FILE
done