parsed.org

Tips by tag: newline

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
Add Newline When Saving Files by cygnus on Feb 16, 2005 02:30 PM

Emacs can be configured to add a trailing newline by updating ~/.emacs as follows:

(setq require-final-newline t)
dot-emacseditorselispemacsnewline
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
RSS