Hi,
How i can be sure that lines terminated by LF (ASCII 10) only (no CR)?
thanks,
papori
Hi,
How i can be sure that lines terminated by LF (ASCII 10) only (no CR)?
thanks,
papori
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.
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,
"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.
Last edited by Gareth Jones; 9th May 2012 at 01:20 AM.
You could grep for carriage returns like this:
If that command returns a number greater than zero then the file contains carriage returns.Code:grep -c $'\r' your_file
You could use cat -v to see the carriage returns (denoted by ^M):
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