Please add support for -v option in printf: -v VAR If given, the output is assigned to the variable VAR instead of printed to stdout (comparable to sprintf() in some way) Example: val1="111" val2="222" printf -v var '%s_%s' "$val1" "$val2" echo "$var"