Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output format issue

Status
Not open for further replies.

LsuBigDog1

Programmer
Feb 13, 2007
2
US
when outputting a money amount, the format is x,xxx,xxx.xx,
but if there a 0 before the comma. The 0 is dropped and looks like x,xxx,xx.xx.
 


cat $finqual/cashfin | sed 's/^Grand Total/x x x Grand total/g' | cut -d" " -f4- |
awk '/STARTED ON UNIX/ { startHH = substr($0,1,2); startMI = substr($0,4,2) }
/FINISHED ON UNIX/ { endHH = substr($0,1,2); endMI = substr($0,4,2) }
/CITRPPB_THREAD.._rep01/ { threadCount++ }
/Grand Total/ { if ( totalCount == 0 ) { totalCount = substr($0,21,5); totalAmount = substr($0,28,11) } }
END {

totalCountRemaining = totalCount
if ( totalCountRemaining / 1000 >= 1 )
{
wholenumber = sprintf("%i",totalCountRemaining / 1000)
totalCountFormatted = sprintf("%i,",wholenumber)
totalCountRemaining -= ( wholenumber * 1000 )
}
totalCountFormatted = sprintf("%s%03i",totalCountFormatted,totalCountRemaining)

totalAmountRemaining = totalAmount
if ( totalAmountRemaining / 1000000 >= 1 )
{
wholenumber = sprintf("%i",totalAmountRemaining / 1000000)
totalAmountFormatted = sprintf("%i,",wholenumber)
totalAmountRemaining -= ( wholenumber * 1000000 )
}
if ( totalAmountRemaining / 1000 >= 1 )
{
wholenumber = sprintf("%i",totalAmountRemaining / 1000)
totalAmountFormatted = sprintf("%s%03i,",totalAmountFormatted,wholenumber)
totalAmountRemaining -= ( wholenumber * 1000 )
}
totalAmountFormatted = sprintf("$ %s%03.2f",totalAmountFormatted,totalAmountRemaining)

startAP = endAP = "am"
if ( startHH == 0 ) { startHH = 12 }
if ( startHH > 12 ) { startHH -= 12; startAP = "pm" }
if ( endHH == 0 ) { endHH = 12 }
if ( endHH > 12 ) { endHH -= 12; endAP = "pm" }
startTime = sprintf("%i:%02i %s",startHH,startMI,startAP)
endTime = sprintf("%i:%02i %s",endHH,endMI,endAP)
printf("<P><B>run.cash</B> started at %s and completed at %s.<BR>",startTime,endTime)
printf("(%i threads)<BR>",threadCount)
printf("Total payments: <B>%s</B> Amount: <B>%s</B>",totalCountFormatted,totalAmountFormatted)
}'
 
Change %03.2f to %06.2f. The first figure is the entire field width, including the decimal point and the digits that follow it.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top