printf

Official Description

Formats and prints data.

Syntax

printf FORMAT [ARGUMENT]...

Options

None

Oddities

Available in ksh93 and beyond.

Format is similar to the C language printf function.

Example

$ float f=8.78
$
$ printf "Float contains %f\n" $f
Float contains 8.780000
$
$ printf "Float contains %.2f\n" $f
Float contains 8.78
$
$ printf "Float contains %10.2f\n" $f
Float contains       8.78
$
				

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.