I have a problem with execution of a while loop, I have found out that the problem involves the execution of the set command, the assigment of the \n character to an environmental variable constitutes a problem. Why does it happen and how to solve it?
my code is:
echo "Enter a filename:\c" read fname terminal=`tty` exec < $fname nol=0 now=0 while read line do nol=`expr $nol + 1` set $line now=`expr $now + $#` done echo "Number of lines:$nol" echo "Number of words:$now" exec < $terminal
When it encounters a line with nothing but a newline character in it, it prints system data and all of the variables:
CINNAMON_VERSION='1.8.8' COLORTERM='gnome-terminal' (...) fname='drunk' line='' nol='19' now='137' terminal='/dev/pts/0'
(...) indicates omission of an entire block of system data