I used the bash commands to append several lines to multiple configuration files:
> for filename in *.ovpn; do
> printf 'configurationscript-security 2\nup /etc/openvpn/update-resolv-conf\ndown /etc/openvpn/update-resolv-conf' >> $filename;
> done
However the control character “^M” appeared at end of each line in the configuration file:

I opened the files in vim, the files before bash commands looked like as folows:

I am curious why “^M” appears at end of each line? Thanks.
It is Windows’ carriage return, use
dos2unixto convert file. Vim recognize the file format and displays it correctly.