#!/bin/rc # hex: convert decimal numbers to hex or vice versa (-d) rfork e fn usage{ echo 'usage: hex [ -d ] [ num ... ]' >[1=2] exit usage } h2d=() while(~ $1 -*){ switch($1){ case -d h2d=1 case * usage } shift } switch($#*){ case 0 cat /fd/0 case * echo $* } | { if(~ $h2d 1) echo ibase'='16 if not echo obase'='16 tr a-f' ' A-F\xa } | bc