PDA

View Full Version : Newline character



joegumbo
29th May 2007, 11:20 PM
Hi,
I just edited my fstab so that I can use my parallel port zip drive. Even though it works, i keep getting an error message. I'm told that i need a newline character at the end of my entry in fstab. I've googled, etc but even though I can find discussion referring to newline, no one seems to have posted the actual character to use at the end on an entry to indicate a newline. In JAVA, it's \n, but I don't know the symbol for GNU/Linux.

Thank you,
-Joe G.

brunson
29th May 2007, 11:26 PM
Open your fstab in vi, go to the last line and hit "O" (capital Oh) to open a new line after the one you're on, then escape to get out of insert mode, then "dd" to delete the line you just added, then 'ZZ' to save the file and exit. You now have a newline at the end of your fstab.

pete_1967
29th May 2007, 11:58 PM
Hi,
In JAVA, it's \n, but I don't know the symbol for GNU/Linux.


Newline character can be several different thing depending on your encoding, '\n' is the most common, but it can also be 'U+000A' which is Unicode for LF (line feed). Also, depending on system, the end of the line varies:
LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, etc.), BeOS, Amiga, RISC OS, and others
CR+LF: DEC RT-11 and most other early non-Unix non-IBM OSes, CP/M, MP/M, MS-DOS, OS/2, Microsoft Windows
CR: Commodore machines, Apple II family and Mac OS up to version 9

Carriage return (CR) is commonly represented with '\r'

As a general rule, you should always end the file with a blank line or you may get complaints in your program's logs (or it fails to work at all as happened to you).

clearer
30th May 2007, 12:28 AM
In java (and a lot of other programming langauges) you use \n to represent the newline character, but it's not actually the real newline character (that is, it's not the newline character which your system sees -- anyways, it's too characters and not one -- \ and n).

joegumbo
30th May 2007, 02:42 AM
Hi brunson, pete_1967 and clearer!

It's OK now. I followed brunson's advice and it worked perfectly!

Thank you for the lessons! I learned alot.

-Joe