diff --git a/bin/.bin/conversion/hex2rgb b/bin/.bin/conversion/hex2rgb new file mode 100755 index 00000000..c85c8436 --- /dev/null +++ b/bin/.bin/conversion/hex2rgb @@ -0,0 +1,13 @@ +#!/bin/sh +# https://stackoverflow.com/questions/7253235/convert-hexadecimal-color-to-decimal-rgb-values-in-unix-shell-script/7253786#7253786 +hexinput="$(echo $1 | tr '[:lower:]' '[:upper:]')" # uppercase-ing +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