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

In reply to Re: Windows and UNIX end of line characters by oko1
in thread Windows and UNIX end of line characters by merrymonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.