I'm having a hard time reading a file stored in a variable. it should be straightforward but somehow I'm missing something, can't find out what?
count=0
mip="$(<fila.txt)"
while read -r line
do
count=`expr $count + 1`
echo "line $count "
done < $mip
it's a really basic and simple script which count the number of lines like so, but when I used a variable done < $mip instead of the file name done < fila.txt. the script just outputs the file content like cat fila.txt instead of counting the lines.
line 1
line 2
line 3
line 4
line 5
line 6
any ideas ??
done < fila.txt