The printf command inserts arguments into a user-defined string of text, creating formatted output.
# To print a text message:
printf "<%s\n>" "<Hello world>"
# To print an integer in bold blue:
printf "<\e[1;34m%.3d\e[0m\n>" <42>
# To print a float number with the Unicode Euro sign:
printf "<\u20AC %.2f\n>" <123.4>
# To print a text message composed with environment variables:
printf "<var1: %s\tvar2: %s\n>" "<$VAR1>" "<$VAR2>"
# To store a formatted message in a variable (does not work on Zsh):
printf -v <myvar> <"This is %s = %d\n" "a year" 2016>
# To print a hexadecimal, octal and scientific number:
printf "<hex=%x octal=%o scientific=%e>" 0x<FF> 0<377> <100000>