Skip to content

Instantly share code, notes, and snippets.

@namklabs
Last active December 15, 2015 18:58
Show Gist options
  • Save namklabs/5307270 to your computer and use it in GitHub Desktop.
Save namklabs/5307270 to your computer and use it in GitHub Desktop.
output a random octet, show the values of each bit in an octet, and output the actual decimal number in bash currently in use on a geeklet on my desktop :)
# | sed "s/^\([0-1]\)\([0-1]\)\([0-1]\)\([0-1]\)\([0-1]\)\([0-1]\)\([0-1]\)\([0-1]\)$/\1 \2 \3 \4 \5 \6 \7 \8/g" |
r=$(($RANDOM % 255 + 1)); echo "obase=2;${r}" | bc | sed "s/\$/ \\`echo -e '\n\r'`128 64 32 16 8 4 2 1\\`echo -e '\n\r'`${r}/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment