Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

awk printf printing extra commas

My script, part of creating html tables in email using awk, printing additional commas (,)

`if (m_premium > mp) {printf ("%s,%.2f,%s\n","<td bgcolor=pink>",m_premium,"TiB</td>");}`

Output is
<td bgcolor=pink>,60.03,TiB</td>
There two extra commas; ie the output should be <td bgcolor=pink>60.03 TiB</td>

Thanks in advance

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The commas you see are those from your format string.

"%s,%.2f,%s\n"

If they bother you, remove them.

Everything in a printf format string which is not part of a conversion specifier or the two-character sequence %% is a character that is printed verbatim; the commas you wrote have no special meaning.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading