Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I print the '%' character with 'printf'?

Tags:

printf

perl

Simple problem that I can't figure out...

How can I print a '%' character within a printf string? The code below prints it, but gives an 'invalid conversion' error as well.

printf "\t\t".$hour."00 HRS\t=>\t%.2f\t%.2f\t%.1f\%\n", $total, $max15, ($max15/$total*100);

Should output something like:

        0000 HRS    =>    3125.19    898.02    28.7%
like image 361
Zaid Avatar asked Jul 09 '09 08:07

Zaid


1 Answers

You would use %%, not \% (from man printf)

like image 199
mirod Avatar answered Sep 27 '22 18:09

mirod