How to avoid the truncating of multiple spaces into a single space while reading a line from a file?

consider the small piece of code

while read line
do
echo $line
done < example

content of example file

sadasdasdasdsa                          erwerewrwr  ergdgdfgf rgerg             erwererwr

the output is like

sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr

the multiple spaces are getting truncated while reading, is there any way to avoid that??:confused:

Quote the variable:

echo "$line"

Thankyou Franklin.....:slight_smile:

This will still truncate any leading and trailing spaces.

If you need to keep them you can just use read and REPLY:

while read
do
    echo "$REPLY"
done < example

Thank you Chubler:)