Published on

Formatted output with printf

Authors
  • Mehdi Akiki avatar
    Name
    Mehdi Akiki
    Twitter

Use printf for controlled formatting:

printf "%s\n" "Hello, world"
printf "%04d\n" 7  # prints 0007

Tip: printf is consistent across shells and avoids echo's option parsing quirks.

I build and scale reliable production systems. Open to full-time and freelance work with U.S.-based teams that value ownership and execution.

Got something in mind?

Book a Discovery Call