[GRASS5] Rgb to hex question

Hamish hamish_nospam at yahoo.com
Sun May 22 20:00:04 EDT 2005


> I need to transform r:g:b triplets to hexidecimal colors in a bash
> shell script. Does anyone have an expression that will do that?

awk with %x or %X:


echo 255 | awk '{printf("%x\n", $1)}'


echo 255:255:255 | tr ':' ' ' | awk '{printf("%X:%X:%X\n", $1, $2, $3)}'



Hamish




More information about the grass-dev mailing list