How to add a carriage return as a character to a file?
If you're using vim
you can enter insert mode and type 'CTRL-v CTRL-m'. That ^M is the keyboard equivalent to \r. (see Insert the carriage return character in vim)
Inserting 0x0D in a hex editor will do the task.
SHELLVAR=$(echo -ne "blablabla\r")
See the echo
man page — the -e
option causes echo to interpret backslash escapes.
Also, at least in bash's normal edit mode, the same control-v control-m sequence works to insert a carriage return character literally; it will show as ^M