LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   form feed,new line and carriage return (https://www.linuxquestions.org/questions/linux-newbie-8/form-feed-new-line-and-carriage-return-4175455756/)

nicksu 03-27-2013 04:05 AM

form feed,new line and carriage return
 
Hi,can anybody help me clarify the difference between a form feed,a new line and a carriage return ?
So appreciate.

TenTenths 03-27-2013 04:40 AM

All terms that came from early printers:

Form Feed - Tells the printer to advance to the next page. (Back in the days when it was continuous feed paper this relied on the printer knowing the page length, AND the printer having the paper loaded properly)
New Line - Moves the print head down one line.
Carriage Return - Move the print head to the "home", (usually left) position.

colucix 03-27-2013 04:48 AM

Hi. The wikipedia page about Newline is quite exahustive about this topic. Please, take a look at http://en.wikipedia.org/wiki/Newline.

In a few words, different systems use different line terminators and sometimes it represents a (easily managed) problem when importing text files from Windows to Linux and viceversa. Windows uses CR + LF (that is \r\n in escape sequence notation) whereas Linux uses only LF (that is \n). Some systems provide the dos2unix and unix2dos tools to make the conversion, but there are other ways to change the newline terminators using sed, perl, awk and so on.

nicksu 03-27-2013 04:54 AM

Quote:

Originally Posted by colucix (Post 4919757)
Hi. The wikipedia page about Newline is quite exahustive about this topic. Please, take a look at http://en.wikipedia.org/wiki/Newline.

In a few words, different systems use different line terminators and sometimes it represents a (easily managed) problem when importing text files from Windows to Linux and viceversa. Windows uses CR + LF (that is \r\n in escape sequence notation) whereas Linux uses only LF (that is \n). Some systems provide the dos2unix and unix2dos tools to make the conversion, but there are other ways to change the newline terminators using sed, perl, awk and so on.

thank you guys

David the H. 03-28-2013 04:52 AM

For that matter, most of the ascii non-printing character range descends from the early days of computing, when they were used for various communication and peripheral control situations. Nowadays most of them just sit there unused, except for CR and LF, which are used as line endings, and a couple of others like null and tab.

The first 000-032 plus 177 are considered the regex [:cntrl:] character class. From man ascii:
Code:

      000  0    00    NUL '\0'
      001  1    01    SOH (start of heading)
      002  2    02    STX (start of text)
      003  3    03    ETX (end of text)
      004  4    04    EOT (end of transmission)
      005  5    05    ENQ (enquiry)
      006  6    06    ACK (acknowledge)
      007  7    07    BEL '\a' (bell)
      010  8    08    BS  '\b' (backspace)
      011  9    09    HT  '\t' (horizontal tab)
      012  10    0A    LF  '\n' (new line)
      013  11    0B    VT  '\v' (vertical tab)
      014  12    0C    FF  '\f' (form feed)
      015  13    0D    CR  '\r' (carriage ret)
      016  14    0E    SO  (shift out)
      017  15    0F    SI  (shift in)
      020  16    10    DLE (data link escape)
      021  17    11    DC1 (device control 1)
      022  18    12    DC2 (device control 2)
      023  19    13    DC3 (device control 3)
      024  20    14    DC4 (device control 4)
      025  21    15    NAK (negative ack.)
      026  22    16    SYN (synchronous idle)
      027  23    17    ETB (end of trans. blk)
      030  24    18    CAN (cancel)
      031  25    19    EM  (end of medium)
      032  26    1A    SUB (substitute)
      033  27    1B    ESC (escape)
      034  28    1C    FS  (file separator)
      035  29    1D    GS  (group separator)
      036  30    1E    RS  (record separator)
      037  31    1F    US  (unit separator)

      177  127  7F    DEL


chrism01 03-28-2013 07:10 PM

The whole table is here for ref http://www.asciitable.com/


All times are GMT -5. The time now is 04:23 PM.