#!/bin/ksh # ----------------------------------------------------------------------- # Filename: dumpdata.ksh # Purpose: Dump first record of binary file according to C-language # definition to see if the data and layout match. # Author: Frank Naude, Oracle FAQ # ----------------------------------------------------------------------- DATAFILE=y.data # Binary data file MAPFILE=y.map # Map file - C field definitions (see sample below) STARTPOS=16 # Offset of fist record in DATAFILE cat $MAPFILE | while read line do X=`echo $line | cut -d\[ -f 2` FLD=`echo $line | cut -d\[ -f 1` # get variable name BYTES=`echo $X | cut -d\] -f 1` # get variable length # Map the variable to the data file... VAL=`od -j $STARTPOS -N $BYTES -c $DATAFILE | cut -c11- | tr -s '\t' ' '` echo "$FLD len=$BYTES val=[$VAL]" ((STARTPOS=STARTPOS+BYTES)) done VAL=`od -j $STARTPOS -N 20 -c $DATAFILE | cut -c11- | tr -s '\t' ' '` echo "First 20 bytes of 2nd record = [$VAL]" # Sample MAPFILE: # --------------- # char rowid[18]; # char ename[6]; # unsigned char sal[8]; # unsigned char comm[8]; # char car_reg[8]; #