Introduction

The title of this documentation is admittedly ambiguous, but it’s difficult to be more specific. When you’re developing or writing text, unwanted characters may appear in your files, such as tabulations on empty lines, “^M” characters at the end of each line, or similar artifacts depending on the editor you’ve chosen.

Here’s how to save precious bytes :-p and most importantly, make your documents “clean”.

Removing ^M Characters at the End of Lines

Have you used Windows Wordpad? Too bad, why not use a real OS? :-p Use this command on your file to clean it:

1
perl -pi -e 's:^V^M::g' my_dirty_file > my_clean_file

Removing Empty Lines

1
sed '/./,$!d' my_dirty_file > my_clean_file

or

1
tr -d "\n" < file1 > file2

Last updated 20 Sep 2009, 15:07 CEST. history