User Tools

Site Tools


Remove ^M CR (carriage return) from output/file

^M is a carriage return (CR), which can be specified as \r for tr or within $'…'. \n specifies a line feed (LF), which is ^J. A Unix line ending is LF, and a Windows line separator is the two-character sequence CR-LF, so Windows text files viewed under a Unix system such as Linux or macOS look like they have ^M at the end of each line except on the last line which is missing its final newline.

You can remove carriage returns from a file with tr with

tr -d '\r' <somefile.txt > && mv somefile.txt
SOMEOUTPUT | tr -d '\r'


docu/csheet/sysadm/script/bash/cr_remove_tr.txt · Last modified: 2020/05/09 11:07 by admin