Skip to content

Instantly share code, notes, and snippets.

@frowing
Created January 22, 2014 16:54
Show Gist options
  • Save frowing/8562420 to your computer and use it in GitHub Desktop.
Save frowing/8562420 to your computer and use it in GitHub Desktop.
Converts HEX to RGB
#!/bin/sh
# hextorgb.sh
hexinput=`echo $1 | tr '[:lower:]' '[:upper:]'` #uppercaseing
a=`echo $hexinput | cut -c-2`
b=`echo $hexinput | cut -c3-4`
c=`echo $hexinput | cut -c5-6`
r=`echo "ibase=16; $a" | bc`
g=`echo "ibase=16; $b" | bc`
b=`echo "ibase=16; $c" | bc`
echo $r $g $b
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment