Saturday, April 15, 2023

How to remove (^M) characters from a file in Linux

The control characters "^M" in a text file are actually the line endings used by Windows/DOS operating systems. These characters can cause issues when you try to use the file in Linux. Fortunately, it is easy to remove them using the tr command

tr -d '\r' < original_file.txt > new_file.txt


That's it! This is a quick and simple way to remove the control characters "^M" from a text file in Linux.

No comments:

Post a Comment