I am exporting data from a table with 4 columns into a file. The 4th column contains amount which is decimal(11,2) with values ranging from 0.00 to 999999999.99. I need to mail this file to the users but before doing that i need to format the amount column as 999,999.00 instead of 999999.00
awk 'BEGIN{FS=","}
function cfmt(n , s) {
s = (ThouSep ? ThouSep : ",") "&" # US convention the default
while ( n ~ /^ *[-+(]? *[0-9][0-9][0-9][0-9]/ )
sub ( /[0-9][0-9][0-9]([^0-9].*|$)/, s, n )
return n
}
{
print cfmt($4)
}
' file