# printf

printf

respects locale, may have to set LC_NUMERIC=C to get internationally agreed behaviour.

format placeholder syntax

%[parameter][flags][width][.precision][length]type

parameter

n$, specify parameter position, missing in shells and gnu coreutils printf.

flags

width

minimum width of output. allows dynamic value w/ *.

precision

maximum limit, for floating point round digitsafter decimal point, for string truncate. allows dynamic value w/ *. following examples behave same.

printf '%.2f' 42.239
printf '%.*f' 2 42.239

length

can be omitted.

type