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$
4
  • 1
    use %% to print a %
    – Archemar
    Jun 25, 2019 at 9:23
  • 1
    thanks. it works.. please add this answer.. i will accept it
    – Kamaraj
    Jun 25, 2019 at 9:24
  • 1
    I get just %</td>. No double ts.
    – muru
    Jun 25, 2019 at 9:27
  • 1
    The dupe is not an exact duplicate, but the issue and the solution is the same. It's either that or closing it as "off-topic (typo)".
    – Kusalananda
    Jun 25, 2019 at 9:28

1 Answer 1

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.

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.