Unix script appends ^M at end of each line

bash, shell, unix

Solution

I'm not sure how `echo` could be producing `^M` characters but you can remove them by running `dos2unix` on your file, like this:

dos2unix /cust/vivek.txt

Problem

I have a Unix shell script which does the following: - creates a backup of a file - appends some text to a file Now in #2 if I insert a text, ^M gets appended on all the lines of the file. For example: ``` echo " a" >> /cust/vivek.txt echo " b" >> /cust/vivek.txt vi vivek.txt abc^M bcd^M a^M b^M ``` Any way to avoid this?

Original source