printf
Format and print ARGUMENT(s) according to FORMAT, using C printf syntax (% escapes for cdeEfgGiosuxX, \ escapes for abefnrtv0 or \OCTAL or \xHEX). toybox
On Linux
Linux
printf FORMAT [ARGUMENT...]
Several platforms
Format and print text.
Print a text message
printf "%s\n" "Hello world"IdentifyPrint formatted message multiple times with different strings
printf "%s\n" string1 string2 ...IdentifyPrint an integer in bold blue
printf "\e[1;34m%.3d\e[0m\n" 42IdentifyPrint a float number with the Unicode Euro sign
printf "\u20AC %.2f\n" 123.4IdentifyPrint a text message composed with environment variables
printf "var1: %s\tvar2: %s\n" "$VAR1" "$VAR2"IdentifyStore a formatted message in a variable (does not work on Zsh)
printf -v myvar "This is %s = %d\n" "a year" 2016IdentifyPrint a hexadecimal, octal, and scientific number
printf "hex=%x octal=%o scientific=%e\n" 0xFF 0377 100000Identify