in reply to Windows and UNIX end of line characters

To address the original problem - i.e., seeing all the characters in the file - you could always use "bvi" ("binary Vi"). If you don't have access to a system that can run "bvi", you could always just fake it with Perl:

#!/usr/bin/perl -w use strict; die "Usage: ", $0 =~ /([^\/]+)$/, " <file>\n" unless @ARGV; open my $fh, $ARGV[0] or die "$ARGV[0]: $!\n"; binmode $fh; my ($hex, $char, $count); { my $res = sysread $fh, my $s, 1; if ($res){ $hex .= sprintf("%02X ", ord($s)); $char .= $s =~ /[[:print:]]/ ? $s : '.'; } if ((++$count % 20 == 0) || !$res){ printf "%-60s%4s%-20s\n", $hex, ' ', $char; $hex = $char = undef; } redo if $res; } close $fh;

Sample output for Unix text file (note '0A' EOLs):

ben@Jotunheim:/tmp$ ./pbvi unix.txt 4C 69 6E 65 20 6F 6E 65 0A 4C 69 6E 65 20 74 77 6F 0A 4C 69 Line o +ne.Line two.Li 6E 65 20 74 68 72 65 65 0A 4C 69 6E 65 20 66 6F 75 72 0A ne thr +ee.Line four.

Sample output for Windows text file (same file, converted):

ben@Jotunheim:/tmp$ ./pbvi windows.txt 4C 69 6E 65 20 6F 6E 65 0D 0A 4C 69 6E 65 20 74 77 6F 0D 0A Line o +ne..Line two.. 4C 69 6E 65 20 74 68 72 65 65 0D 0A 4C 69 6E 65 20 66 6F 75 Line t +hree..Line fou 72 0D 0A r..

Update: Corrected by wrapping 'if' statement around the first two assignments in the loop; without it, the script produced a superfluous '00' at the end of each file.


--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf

Replies are listed 'Best First'.
Re^2: Windows and UNIX end of line characters
by merrymonk (Hermit) on Aug 10, 2010 at 19:24 UTC
    That looks something else that is definiteley worth trying.