Hi, i am writing a script to generate a summary report for my data text file
my data in my text file goes like this:
MacOS:Mary Abraham:53.48:88:38
Windows in lala:Mary Abraham:22.30:23:22
lala in Windows:John Goodman:33.60:121:12
Hello world:Mr Tian:23.30:23:10
Windows in 31 days:John Badman:33.70:212:13
and this is my code to print the data out
BEGIN{
FS=":"
print " "
print "===================================Summary Report================================================="
print "=================================================================================================="
print "|Title | \tAuthor \t|Price \t|Qty Available|Qty Sold|Total|"
print "=================================================================================================="
}
{
title = $1
author = $2
price = $3
available = $4
sold = $5
total = $3 * $5
printf("%s\t %s\t$%s\t\t%s\t%s\t$%s\n", title, author, price, available, sold, total)
}
END{
}
the output will be
I will like to know is there any ways I can change my code to make sure that the data in each column will align properly under the respectively title? Thank You