<---- template headericclude ----->
LF (ASCII 10) only (no CR)
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2010
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    LF (ASCII 10) only (no CR)

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

    thanks,
    papori

  2. #2
    Join Date
    Aug 2009
    Location
    Waldorf, Maryland
    Posts
    7,343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  3. #3
    Join Date
    Oct 2008
    Posts
    498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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,

  4. #4
    Join Date
    Jul 2011
    Location
    Birmingham, UK
    Age
    41
    Posts
    2,759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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 Images Attached Images
    Last edited by Gareth Jones; 9th May 2012 at 01:20 AM.

  5. #5
    Join Date
    Nov 2006
    Location
    Detroit
    Posts
    8,726
    Mentioned
    62 Post(s)
    Tagged
    0 Thread(s)

    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 Images Attached Images
    OS: Fedora 39 x86_64 | Machine: Lenovo ThinkCentre M91P | CPU: Intel Core i5-2500 (4)@3.30GHz | RAM: 32GB PC3-12800 DDR3 | Disks: Seagate Barracuda ST500DM002 500GB SATA, Seagate Constellation ES.3 ST1000NM0033 1TB SATA | Video: Intel HD Graphics 2000 128MB | Sound: Turtle Beach Santa Cruz CS4630 | Ethernet: Intel 82579LM

Similar Threads

  1. Ascii Art
    By agriz in forum Programming & Packaging
    Replies: 5
    Last Post: 19th December 2011, 07:16 AM
  2. Ascii Tux
    By tw2113 in forum Linux Chat
    Replies: 3
    Last Post: 27th April 2007, 11:51 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
[[template footer(Guest)]]