Removing CTRL M characters

Sometimes if you modify or create a file in Windows or DOS and then copy it to a Linux (well Unix like) file system you get ^M characters at the end of each line. These are annoying when trying to run scripts on files (or things like latex) and can be nicely removed using the vi editor. Open you file with vi and then do:

ESC:%s/^M//g

You can get the ^M by pressing Ctrl V and then Ctrl M.

Advertisements

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

%d bloggers like this: