#!/bin/rc rfork e fn fmt { awk ' BEGIN{ ORS=OFS="" n=0 print "\t" } NF > 1 { for(i=2; i<=NF; i++){ n++ print "0x"$i",", (n%8) ? " " : "\n\t" } } ' } switch($#*){ case 0 name=array case 1 name=$1 case * echo 'usage: chex [name]' >[1=2] exit 'usage' } echo 'char '^$name^'[] = {' xd -b $1 | fmt echo echo '};'