Do While Loop + Read From File + assign line to a variable

Hello,
I am using below code for reading from a file and assigning the values to a variable , but it is loosing the value after the loop , please suggest to retain the value of the variable after the loop ,

while IFS=: read -r line
do
set $dsc=$line
echo 'printing line variable ' $line
done < emp_csv.txt
echo 'printing dsc varaiable' $dsc

Depending on your shell, the set is not needed, and don't expand the variable: dsc=$line

1 Like