LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 04: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, 04:40 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,481

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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, 04:48 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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, 04: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, 04:52 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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, 07:10 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

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


Reply



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 04:28 AM
Java bufferedreader -- how to read carriage return/new line sent over network from C texasone Programming 2 01-20-2012 08:15 AM
Line feed or carriage return-linefeed? Aka \n or \r? stf92 General 10 01-20-2012 12:55 AM
Line wrap on embedded system issues carriage return but no linefeed crunchytheory Linux - Embedded & Single-board computer 4 09-18-2011 12:20 AM
Remove New Line or Carriage return from Text File DIMonS Programming 13 10-01-2007 10:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:29 AM.

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
Open Source Consulting | Domain Registration