On Mon, Jul 25, 2022 at 01:17:38PM +0200, Thomas Schmitt wrote: > #!/bin/bash
> rhex="$(printf '%2.2x' "$r")" As of bash 3.1, you can use printf -v rhex %2.2x "$r" > ghex="$(printf '%2.2x' "$g")" Same. > bstart="$(expr "(" "$r" + "$g" ")" / 2 + "$blue_advantage")" bstart=$(( (r+g)/2 + blue_advantage )) > if test "$bstart" -lt "$blue_base" Not wrong, but you could also use if ((bstart < blue_base)) > for b in $(eval echo $(echo '{'"$bstart"..255..8'}')) for ((b=bstart; b<=255; b+=8)) > bhex="$(printf '%2.2x' "$b")" > echo "#${rhex}${ghex}${bhex}" Oh, is this what the *hex variables are for? Why not just leave them in pseudo-integer form the whole time, and then use a single printf *here* to convert them to hex for output? printf '#%2.2x%2.2x%2.2x\n' "$r" "$g" "$b"