1

i get </ttd> instead of </td> in the below printf. Can someone please explain why. i want % symbol in my output. But it adds extrac t in my output.

awk '{printf("<td>%0.2f`%</td>`\n",$0)}'
bash-4.3$ echo "50" | awk '{printf("<td>%0.2f</td>\n",$0)}'
<td>50.00</td>
bash-4.3$
bash-4.3$ echo "50" | awk '{printf("<td>%0.2f%</td>\n",$0)}'
<td>50.00%</ttd>
bash-4.3$
muru
  • 69,900
  • 13
  • 192
  • 292
Kamaraj
  • 4,295
  • 1
  • 12
  • 18

1 Answers1

4

I can't find any reference of %< neither in man 1 printf nor man 3 sprintf (man awk refer to sprintf), however :

In almost every implementation of printf (C,awk,php,...) one is to use %% to print a single % sign.

Archemar
  • 31,183
  • 18
  • 69
  • 104
  • 1
    There's nothing in [format control letters](https://www.gnu.org/software/gawk/manual/gawk.html#Control-Letters) or modifiers in the GNU awk manual, either. – muru Jun 25 '19 at 09:28