Question: I'm trying to generate a summary report in bash. My text file format's this way:

```
title:composer:price:musical pieces available:musical pieces sold

```

However, in my report output's supposed to be this way :

```
Title       Composer   Price   PiecesAvail   PiecesSold   TotalProfit
Graham      Jack       20.00       10            2           40.00
Zack        Squall      4.00       5             3            7.00

```

Anyone can point me in the right direction? I would have to either calculate the total profit beforehand,or while generating the report.

A sample of the textfile's here:

```
 Graham:Jack:20.00:10:2
 Jack:Squall:4.00:5:3
 Random - One:Jim:5.00:4:1
 RainyDay:Melissa:50.00:2:1

```

I've not thought how to calculate the total profit yet though.

Answer: 
```
awk -F':' '
BEGIN {
    fmt = "%-15s%-11s%5s   %11s   %10s   %11s\n"
    printf fmt, "Title","Composer","Price","PiecesAvail","PiecesSold","TotalProfit"
}
{ printf fmt, $1,$2,$3,$4"     ",$5"     ",sprintf("%.2f   ",$3*$5) }
' file
Title          Composer   Price   PiecesAvail   PiecesSold   TotalProfit
Graham         Jack       20.00       10            2           40.00    
Jack           Squall      4.00        5            3           12.00    
Random - One   Jim         5.00        4            1            5.00    
RainyDay       Melissa    50.00        2            1           50.00  

```
```
#!/bin/sh
awk -- 'BEGIN {
    FS = ":"
    OFS = "||"
    print "Title", "Composer", "Price", "PiecesAvail", "PiecesSold", "TotalProfit"
}
{
    sub(/^[ \t]+/, "", $1); sub(/\r+$/, "", $5)
    printf "%s||%s||%5.2f||%6d||%6d||%8.2f\n", $1, $2, $3, $4, $5, $5 * $3
}' "$@" | column -t -s '||'

```

Usage

```
sh script.sh file

```

Output:

```
Title           Composer    Price    PiecesAvail    PiecesSold    TotalProfit
Graham          Jack        20.00        10              2           40.00
Jack            Squall       4.00         5              3           12.00
Random - One    Jim          5.00         4              1            5.00
RainyDay        Melissa     50.00         2              1           50.00

```