I get 2 different results for this line in Cygwin. In XP, columns (the correct output) and Win7 all on one long line
awk '{$0=sprintf("%.1f%.1f%4s", $1,$2,$3);gsub(/ /,"0");gsub(/\./,"")}1' /cygdrive/e/$1.txt > /cygdrive/e/$1.bod
Thanks
Input: (35030035.txt)
4.65 2.38 15
4.71 3.36 775
3.52 3.03 53
4.05 3.33 71
3.22 2.99 346
XP output: (35030035.bod) This is correct output
47240015
47340775
35300053
40330071
32300346
Win7 output:(35030035.bod)
4724001547340775353000534033007132300346
Looks like the line terminators are messed up. Try explicit \n
in your sprintf
function.
sprintf("%.1f%.1f%4s\n", $1,$2,$3)
or instead of 1
do a print $0
.
awk {$0=sprintf("%.1f%.1f%4s", $1,$2,$3);gsub(/ /,"0");gsub(/\./,"");print $0}'
Alternative use RS
variable of awk
to set the new lines.