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.
In reply to Re: Windows and UNIX end of line characters
by oko1
in thread Windows and UNIX end of line characters
by merrymonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |