I have 3 files in a directory. The files are named as below MSDOS
PCDOS
filename.txtThe file filename.txt contains the following 1 line
*****DOS
When I run the following while loop I get the following output
while read r
do
echo $r
done < filename.txtOutput is
MSDOS PCDOS
I would have expected the output to be
****DOS.What am I doing wrong?

When the echo command executes, the astric is treated as a meta character. The expansion says to list all files in the current directory that end with DOS.To prevent the expansion, surround the variable with quotes:
echo "$r"
That worked. Thank you for the answer as well as the explanation.
