Problem in loop

hi I'm jus getting some input from the user and copy to a file line by line using for loop till the user enters ^b. But when I cat the file many junk characters are present. How can fix this issue?

echo "Enter your input file"
         while read -r LINE
         do
         echo $LINE >> CONFIG_SPEC_FILE
               if [ "$LINE" = "^b" ];then
               break
               fi
         done

input given is

     element * CHECKEDOUT
     element \app\... .../ch_ananth/LATEST
     element \app\... /main/LATEST 
     load \app\bala
     load \app\HomeProject
     load \app\Build
cat CONFIG_SPEC_FILE

output I get includes many unknown characters along with the input.

Thanks
Ananth

Try this:

cfgFile="CONFIG_SPEC_FILE"
while true
do
	echo "Enter your data [exit to finish]:"
	read LINE
	
	[ "${LINE}" == "exit" ] && break
	
	echo "${LINE}" >> "${cfgFile}"
done

# cat CONFIG_SPEC_FILE
element * CHECKEDOUT
element app... .../ch_ananth/LATEST
element app... /main/LATEST
load appbala
load appHomeProject
load appBuild

Felipe, It worked out. Thanks :slight_smile:

---------- Post updated at 04:26 AM ---------- Previous update was at 03:56 AM ----------

Felipe the output I get excludes "\" which is in the input.
Expected output is

code
element * CHECKEDOUT
element \app\... .../ch_ananth/LATEST
element \app\... /main/LATEST
load \app\bala
load \app\HomeProject
load \app\Build

...
read -r LINE
...

--ahamed

Thanks ahamed...