#! /usr/bin/tclsh if { $argc eq 0 } { puts "Печать hex-дампа файла Использование: $argv0 имя_файла" exit 0 } if ![file exists $argv] { puts "Файл не найден" exit 1 } set fl [open $argv r] fconfigure $fl -translation binary while {![eof $fl]} { set str "" puts -nonewline [format "%08x " [tell $fl]] set a [read $fl 16] foreach sym [split $a {}] { set c [scan $sym %c] puts -nonewline [format "%02x " $c] if {$c < 32 || $c > 126} { append str . } else { append str [format %c $c] } } puts \t$str } close $fl
пример вывода:
00010c90 5f 31 36 78 31 36 2e 70 6e 67 50 4b 01 02 14 00 _16x16.pngPK.... 00010ca0 14 00 00 00 00 00 00 00 21 00 99 8a b4 a9 08 04 ........!....... 00010cb0 00 00 08 04 00 00 0d 00 00 00 00 00 00 00 00 00 ................ 00010cc0 00 00 a4 01 6c f3 00 00 72 73 73 5f 31 36 78 31 ....l...rss_16x1 00010cd0 36 2e 70 6e 67 50 4b 01 02 14 00 14 00 00 00 00 6.pngPK......... 00010ce0 00 00 00 21 00 4d de a0 f7 37 04 00 00 37 04 00 ...!.M...7...7.. 00010cf0 00 0f 00 00 00 00 00 00 00 00 00 00 00 a4 01 9f ................