Fedora Linux Support Community & Resources Center
  #1  
Old 8th May 2012, 09:26 PM
papori Offline
Registered User
 
Join Date: Nov 2010
Posts: 58
linuxfedorafirefox
LF (ASCII 10) only (no CR)

Hi,
How i can be sure that lines terminated by LF (ASCII 10) only (no CR)?

thanks,
papori
Reply With Quote
  #2  
Old 8th May 2012, 09:33 PM
jpollard Online
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,865
linuxfirefox
Re: LF (ASCII 10) only (no CR)

That is the default on Linux.

See: http://soft.zoneo.net/Linux/dos_to_unix.php

The referenced program is in the package dos2unix, though it is simple enough from the examples even without the program.
Reply With Quote
  #3  
Old 8th May 2012, 09:34 PM
assen Offline
Registered User
 
Join Date: Oct 2008
Posts: 492
linuxfedorafirefox
Re: LF (ASCII 10) only (no CR)

Hi,

Many ways - for example, open the file in hex editor - Gnome has one somewhere in the repos, but I'd use Midnight Commander for this (highlight the file, press F3, then F4). Then check what lives at the line's end.

WWell,
Reply With Quote
  #4  
Old 9th May 2012, 01:18 AM
Gareth Jones Offline
Official Gnome 3 Sales Rep. (and Adminstrator)
 
Join Date: Jul 2011
Location: Birmingham, UK
Age: 32
Posts: 2,771
linuxfirefox
Re: LF (ASCII 10) only (no CR)

"LF" is the normal Unix/Linux convention, and should be the default with any text editor run in Fedora (unless opening a file which already uses another line ending convention). "CR+LF" is for DOS/Windows, and "CR" alone for Mac OS (< OS X anyway, I'm not sure what OS X does, it being a Unix derivative). Unicode/UTF-8 technically complicate things further, but that's rarely an issue in practise.

Different text editors have their own methods for overriding defaults. For example, in Vim I could type ":set ff=unix" before saving a file I want to convert to LF-only line endings. GEdit also has a drop-down menu in its save dialogue window (see the attached screen-shot).

The terminal commands dos2unix, mac2unix, unix2dos and unix2mac convert existing files. See jpollard's post and link for more information on the dos2unix package.
Attached Thumbnails
Click image for larger version

Name:	Screenshot at 2012-05-09 01:02:48.png
Views:	46
Size:	29.0 KB
ID:	23047  

Last edited by Gareth Jones; 9th May 2012 at 01:20 AM.
Reply With Quote
  #5  
Old 9th May 2012, 04:21 AM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,685
linuxfedorafirefox
Re: LF (ASCII 10) only (no CR)

You could grep for carriage returns like this:
Code:
grep -c $'\r' your_file
If that command returns a number greater than zero then the file contains carriage returns.

You could use cat -v to see the carriage returns (denoted by ^M):
Attached Thumbnails
Click image for larger version

Name:	crlf.png
Views:	39
Size:	99.8 KB
ID:	23053  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
Reply

Tags
ascii

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ascii Art agriz Programming & Packaging 5 19th December 2011 06:16 AM
Ascii Tux tw2113 Linux Chat 3 27th April 2007 11:51 PM


Current GMT-time: 15:27 (Friday, 24-10-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Covilha - Huai Yot - Masindi