Synopsis
hasc [options] [file name] hasc --help hasc --version
Description
The hasc
utility lists its input as hexadecimal character codes, with the original
ASCII characters displayed on the right. With the
-c or --color
option it will color code the characters. Each line begins with it's offset,
also in hex. hasc can be used for looking at the structure of a binary file.
hasc is similar to the xxd(1) program, but both provide different
options. The most notable option that hasc provides, and
xxd doesn't, is the coloring of control codes, using the -c
option. However, xxd
can regenerate binary files from listings that look like its output, allowing
you to use it as a simple binary file editor.
hasc can't do that. The program hasci(1)
(the extra âiâ stands for âinteractiveâ) can be used to explore a binary file
interactively, using a similar format and color coding scheme as
hasc.
hasc
uses the file listed after it's options, if any, as input. If no file name is
specified it uses its standard input. The special
â--â option
can be used to indicate the start of the file name, which is useful if the
file begins with a
â-â character.
The -c option works by causing hasc to generate VT
control codes that instruct a terminal to display different parts of the text
in different colors. These codes may not generate the desired output on all
terminals. Piping the output of hasc into a pager like
more(1) or less(1)
will not work because these programs do not understand the control codes. The
output of hasc
can be redirected into a file and displayed in a web browser by converting it
into HTML using the utility vt2html(1).
By default hasc
does not display duplicate lines. If it finds that there are several
consecutive lines which are identical then it will output the first one and
then a line containing only an asterisk (*), in the same way as
od(1)
does. You can work out how many duplicate lines there were by comparing the
address fields of the lines before and after the asterisk. The
-v option makes hasc display duplicate lines in full, just as it does for od.
Note that characters which are not part of the normal printable ASCII
range (32–126) are not printed in the
ASCII part of the output, unless the -e option
is used. Normally a dot (.) is used to represent a character that might
otherwise be unprintable. With the -c option
some other symbols are also used for certain control characters (see below).
Options
- -a, --no-ascii
Suppress the ASCII characters on the right, making the output more like that of od.
- -c, --color, --colour
Uses color coding by inserting VT control codes into the output. The address at the start of each line is colored yellow. Both the hex character codes and the ASCII characters are colored green if the character code is above the standard range of printable ASCII characters (127 and above), or red if it is a control code (below 32). When
-cis turned on recognized control codes are given the following symbols in the ASCII part of the output:0 null (0x00), a bell/alert (0x07), b backspace (0x08), t tab (0x09), n line feed/newline (0x0A), v vertical tab (0x0B), f form feed (0x0C), r carriage return (0x0D), and e escape (0x1B).
These are only used when coloring is turned on, because the red coloring is needed to distinguish them from normal letters. Blue is used for the asterisks showing duplicate lines.
- -e, --extended-ascii
Print characters with codes above 126 in the ASCII display instead of replacing them with dots.
- -g, --no-gaps
Suppress the gaps between the hex character codes.
- -H, --help
Give a brief description of what hasc does, with a synopsis showing allowable options.
- -h, --half-width
Print half length lines. This makes the output suitable for a 40 column display, by printing only 8 bytes of input per line of output. It also prints only one space (rather than 2) after the address field, unless the colon has been suppressed with the
-ooption.- -o, --no-colon
Suppress the colon after the address field and print a space instead.
- -V, --version
Print the name and version number of the program.
- -v, --output-duplicates
Suppress the asterisks that mark duplicate lines. With this option consecutive lines that are identical will be displayed in full.
Bugs
It assumes that the output device likes VT codes.
The yellow offset numbers don't show up very well on a white background.
Copying
Copyright 1999 Geoff Richards
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English.
Author
Geoff Richards <geoff@laxan.com>
http://ungwe.org/free_software/hasci/
See Also
hasci(1), for displaying files in a similar format to hasc, but allowing the user to navigate the file interactively.
vt2html(1), for converting hasc output into HTML.