parsed.org

Tips by tag: line-endings

Add a Newline to the End of a File by cygnus on Dec 31, 2005 04:09 PM

Use sed to add a newline to the end of a file (this will perform an in-place replacement and create a backup file, MYFILE.bak):

$ sed -i.bak '$G' MYFILE

Some programs, such as Emacs, will omit the trailing newline from a file unless configured to add one. Emacs can be configured to add a newline automatically.

backupcommandsconfigurationeditorsemacsin-placeline-endingsnewlinesedshell
Convert DOS Files by xinu on Jan 20, 2005 10:55 AM

There are a few different ways to convert a DOS file to Unix format, but the most available is probably this:

$ col -bx < dosfile > unixfile
colcommandsconvertdosfilterline-endingsnewlineshellunix
Replace CR/LF with CR by xinu on Jun 07, 2005 11:21 AM

Given an array @slobber, replace all the CR-LF with CR:

foreach (@slobber) {
   s/\015\012$/\n/; print;
}
dosforeachlanguagesline-endingsperlprogrammingsyntaxunix
RSS