Formatting output in columns

I have a file which contains data in below format:

nbkv28s MgmtReporting -> TradingDesk 1
nbkv28s RMBS -> Credits 178
nbkv28s RMBS -> PassThrough 96
nbkv28s RMBS -> Prepayment 111
nbkv28s RMBS -> RMBSHome 370
nbkv28s RMBS -> TradingStrategy 98
nbkvnze RMBS -> RMBSHome 85
nbkvugn GSF -> ABS 165

I want to fromat this data in to seperate columns as shown below, please help:

 
nbkv28s     MgmtReporting -> TradingDesk              1
nbkv28s     RMBS -> Credits                                 178
nbkv28s     RMBS -> PassThrough                          96
nbkv28s     RMBS -> Prepayment                           111
nbkv28s     RMBS -> RMBSHome                            370
nbkv28s     RMBS -> TradingStrategy                     98
nbkvnze     RMBS -> RMBSHome                            85
nbkvugn     GSF -> ABS                                      165
 

I am unable to show the last column properly, it should be well aligned. Even here i cannot show :slight_smile:

#!/usr/bin/perl -w
while (<STDIN>) {
        if (/^([^\s]*)\s+([^\s]+ -> .*) (\d+)$/) { $first=$1;$second=$2;$third=$3;write }
}

format STDOUT =
@<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @##########
$first,$second,$third
.

More info on format
You can tweak the @<<<< bits to get things laid out as you want them.

Does this do what you want? (You may have to adjust the spacing.)

awk '{ x = $2 " " $3 " " $4; printf "%-10s %-30s %4d\n", $1, x, $5}'

I have become fan of awk now.. :b: