LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-27-2013, 05:05 AM   #1
nicksu
Member
 
Registered: Dec 2012
Posts: 35

Rep: Reputation: Disabled
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.
 
Old 03-27-2013, 05:40 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
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.
 
Old 03-27-2013, 05:48 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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.
 
Old 03-27-2013, 05:54 AM   #4
nicksu
Member
 
Registered: Dec 2012
Posts: 35

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by colucix View Post
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
 
Old 03-28-2013, 05:52 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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
 
Old 03-28-2013, 08:10 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find if a file is having return carriage and new line characters ? pradeepdee6 Linux - Newbie 8 01-10-2013 05:28 AM
Java bufferedreader -- how to read carriage return/new line sent over network from C texasone Programming 2 01-20-2012 09:15 AM
Line feed or carriage return-linefeed? Aka \n or \r? stf92 General 10 01-20-2012 01:55 AM
Line wrap on embedded system issues carriage return but no linefeed crunchytheory Linux - Embedded & Single-board computer 4 09-18-2011 01:20 AM
Remove New Line or Carriage return from Text File DIMonS Programming 13 10-01-2007 11:31 AM


All times are GMT -5. The time now is 09:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration