Vidarrus
Vidarrus

Reputation: 175

AWK print - replace comma with dot

I run this command line:

awk -F "\\t" "NR>=%startcounter%&&NR<=%endcounter% { print """UPDATE tArtikel SET fVKNetto =""" $6 """ WHERE cArtNr = """ $1 """ """;}" fil_a.txt file_b.txt

The result is:

UPDATE tArtikel SET fVKNetto =27,67 WHERE cArtNr = 60160 

Is there a easy way in awk to replace the comma, with a dot?
It should be:

UPDATE tArtikel SET fVKNetto =27.67 WHERE cArtNr = 60160 

I found some solutions, but I would like to make it as short as possible. It would be perfect if the command has not to be completely changed.

Thank you for your help!

Note: I use Winawk

Upvotes: 0

Views: 4424

Answers (1)

Jotne
Jotne

Reputation: 41460

This replaces all , with .

awk -F "\\t" "{gsub(/,/,".")} NR>=%startcounter%&&NR<=%endcounter% { print """UPDATE tArtikel SET fVKNetto =""" $6 """ WHERE cArtNr = """ $1 """ """;}" fil_a.txt file_b.txt

Upvotes: 1

Related Questions