Remove Carriage Returns From Text Files Edited on Windows

Sometimes people change text files – that are supposed to run or get processed on a Unix/Linux system – on Windows text editors such as notepad, this messes up the file as Windows puts a carriage return (read as ^M from within vi) at the end of each line and then you won’t be able to execute or process the file correctly, here is the Linux command you can use to remove such invalid characters:

tr -d ‘\r’ “”httpd_clean.conf (remove the double quotations)

where:

tr -> is the command
-d -> to delete a certain character or pattern of characters
‘\r’ -> denotes the carriage return (elly heyya el Enter)
httpd.conf is the input file, it has to be preceded by a ‘httpd_clean.conf -> httpd_clean.conf is the output file, it has to be preceded by a ‘>’

Advertisements

About SoCRaT

Research Support and Infrastructure Engineer, OSS & Linux Geek
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s