Manual Reference Pages  - binformat (1)

NAME

binformat - convert fixed length binary records to text format

CONTENTS

Synopsis
Description
Options
Examples
See Also
License
Copyright
Authors

SYNOPSIS

binformat [options...]

DESCRIPTION

binformat Convert fixed length binary records to text. Specifiers define the size and type of each field, as well as how to format the output, including optionally swapping the byte order.

binformat may be obtained as part of the drm_tools package from: http://sourceforge.net/projects/drmtools/

On many operating systems binformat must be compiled with large file support if it is to read files above a few gigabytes in size. If compiled with the gcc compiler add the command line switches -D_LARGE_FILE_SOURCE -D_FILE_OFFSET_BITS=64 to include large file support. The -i option will show whether or not large files are supported.

OPTIONS

-format <STRING>
 
Description of the conversion from a binary record to text.
STRING is composed of these elements:
Field types
   - 1 byte  read but not emitted
   s 1 byte  character with format %c
   t 1 byte  emit corresponding text from -table file
   c 1 byte  signed integer with format  %d
   w 2 byte  signed integer with format  %d
   l 4 byte  signed integer with format  %d
   g 8 byte  signed integer with format  %lld
   f 4 byte  float with format  %f
   d 8 byte  float with format %df
   k current record number as 8 byte signed integer with format %d

Literals are emitted but not read , 1 byte literal. Also \t, \n and space. "text" n byte literal character string.

Modifiers precede field type and are reset to default after use, they may appear in any order u integer field is unsigned x integer field is unsigned, uses %x instead of %u X integer field is unsigned, uses %X instead of %u o integer field is unsigned, uses %o instead of %u F float field uses %F notation instead of %f e float field uses %e notation instead of %f E float field uses %E notation instead of %f P,p pad int 16, 32, or 64 bit field with one zero byte before/after actual data. gPP is a 6 byte integer, with two leading zero bytes. Swap is applied BEFORE pad bytes are added. %m[.n]% alternate precision for format, m and n are integers # (# is a number composed solely of the digits 0-9) Repeat count on next field ^ swap the bytes in 2,4, or 8 byte fields. For 1 byte fields with a repeat emit back to front. The size of the record is the sum of the read sizes of these types.

-in <FILE> File to read fixed length binary records from. "-" or not specified [Default] reads from stdin.

-out <FILE> Write output to FILE. (Default - write to stdout).

-oops Write out as much as possible on a short read. [Default - exit immediately on a short read].

-table <FILE>
  Specify FILE holding at least 256 text lines corresponding to byte values 0-255. When the t field type is used the corresponding line in FILE is emitted, minus the end of line character.

-sk N
  Start value for k format. Default is 0.

-h -help --help -? --??
  Print the help message. (Default - do not print help message.)

-hexamples
  Print examples. (Default - do not print examples.)

-i Emit version, copyright, license and contact information.( Default - do not emit information.)

EXAMPLES

% binformat -in file.bin -out file.txt -format ’4xc,ug2 ^f’
  Convert a file, printing for each 16 byte record:
unsigned bytes 1-4 each in hexadecimal
a comma
bytes 5-12 as an unsigned 8 byte integer
two spaces
bytes 13-16 as an engineering float, after swapping its bytes
a new line character

% binformat -in file.bin -out file.txt -format ’%8%k" Field1 "5^s3-’\n" Field3 "7xc’
  Convert a file, printing for each 15 byte record:
The record count right justified with width 8
’ Field1 ’
bytes 1-5 in reverse order as text characters
(bytes 6-8 are ignored)
a new line character
’ Field3 ’
unsigned bytes 9-15 in normal order in hexadecimal
a new line character

SEE ALSO

mdump(1), datasniffer(1), binload(1)

LICENSE

GNU General Public License 2

COPYRIGHT

Copyright (C) 2015 David Mathog and Caltech.

AUTHORS

David Mathog, Biology Division, Caltech <mathog@caltech.edu>


drm_tools binformat (1) 0.0.6 OCT 22 2015
Generated by manServer 1.07 from /usr/common/man/man1/binformat.1 using man macros.