#! /bin/bash # vi:set ts=8 sw=4 et sta: # # Author : Clark J. Wang # License: GPLv2 # # $Date$ # $Author$ # $HeadURL$ # $Revision$ # #--------------------------------------------------------------------# hexdump () { local sArg; local B E; for sArg in "$@"; do if [[ "$sArg" == -* && "$sArg" != -[nsv] ]]; then command hexdump "$@"; return $?; fi; done; if [ -t 1 ]; then eval "B=\$'\\033[44m'"; eval "E=\$'\\033[0m'"; fi; echo " 0 1 2 3 4 5 6 7 8 9 A B C D E F |0123456789ABCDEF|" 1>&2; echo "---------+--+--+--+---+--+--+--+---+--+--+--+---+--+--+--+--+----------------|" 1>&2; command hexdump -e '"%06_ax:" 4/1 " %02x" " " 4/1 " %02x" " " 4/1 " %02x" " " 4/1 " %02x" " |"' \ -e '4/1 "%1_p" "'"$B"'" 4/1 "%1_p" "'"$E"'" 4/1 "%1_p" "'"$B"'" 4/1 "%1_p" "'"$E"'|\n"' \ "$@" } #--------------------------------------------------------------------# # example hexdump -n 123 /dev/urandom