#!/bin/bash # hexclock - convert time to a hexadecimal format hour=`date +%H` # Get the current Hour (24 hour format) minute=`date +%M` # Get the current Minute second=`date +%S` # Get the current Second totalsec=`echo "($hour*60+$minute)*60+$second" | bc` # Convert Hour, Minute, Second to total seconds htime="`echo "obase=16; $totalsec/86400" | bc -l`" # Output the hextime as a hex fraction htime=`echo $htime | cut -d'.' -f2 | cut --bytes=1-4` # Format the fraction to not have . and only have first 4 bytes hexhour=`echo $htime | cut --bytes=1` # Hex Hours = First byte of fraction hexmin=`echo $htime | cut --bytes=2-3` # Hex Minutes = Second and Third bytes of fraction hexsec=`echo $htime | cut --bytes=4` # Hex Seconds = Fourth byte of fraction echo -n "The current time in hexadecimal is: " # Nice little formatting message echo $hexhour"_"$hexmin"_"$hexsec # Print results exit