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

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

Reply With Quote
Old 8th May 2012, 09:33 PM
jpollard Offline
Registered User
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 7,346
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
Old 8th May 2012, 09:34 PM
assen Offline
Registered User
Join Date: Oct 2008
Posts: 498
Re: LF (ASCII 10) only (no CR)


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.

Reply With Quote
Old 9th May 2012, 01:18 AM
Gareth Jones Offline
Retired Adminstrator
Join Date: Jul 2011
Location: Birmingham, UK
Age: 34
Posts: 2,761
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:	54
Size:	29.0 KB
ID:	23047  

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

You could grep for carriage returns like this:
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:	51
Size:	99.8 KB
ID:	23053  
OS: Fedora 26 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 7GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote


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 07:16 AM
Ascii Tux tw2113 Linux Chat 3 27th April 2007 11:51 PM

Current GMT-time: 00:09 (Tuesday, 26-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive

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