Linux Commands Reference - Complete Linux Command Guide

Comprehensive Linux command reference with 150+ commands. Search, filter by category, and view detailed usage examples.

Share
Back to commands

printf

Format and print text

Syntax

printf FORMAT [ARGUMENT]...

Common Options

%sString
%dDecimal integer
%fFloating point number
%xHexadecimal number
%oOctal number
%cSingle character
%-10sLeft-align, 10 chars wide
%05dZero-padded 5-digit number

Common Examples

printf "Name: %s\n" "Alice"

Format string

printf "%-10s %5d\n" "Alice" 100

Aligned output

printf "Hex: %x\n" 255

Decimal to hex

printf "Pi: %.2f\n" 3.14159

Round to 2 decimals

printf "%05d\n" 42

Zero-pad number

printf "%s,%s,%s\n" a b c

Multi-argument format

printf "%.1f%%\n" 85.5

Print percentage

printf "%b" "hello\nworld"

Interpret escape sequences

Related Commands

Related Tools

More Code & Dev Tools