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%
Use %% to print a single %
You would use %%, not \% (from man printf)
%% for a single %
This is a bit tricky because the documentation for the template for printf is actually in the documentation for sprintf. You have to catch that line in the middle of the paragraph to know to look there.
On hindsight, there was a crude alternative which would have done the same thing.
Print the '%' symbol as a string:
Instead of \% use %% :)