|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Formatting output in columns
I have a file which contains data in below format: Code:
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: Code:
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
|
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
#!/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. |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
|
#4
|
|||
|
|||
|
Thanks a lot !!
I have become fan of awk now..
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Formatting a line of data into columns | nistleloy | UNIX for Dummies Questions & Answers | 3 | 05-12-2009 04:52 PM |
| formatting the output | ragavhere | Shell Programming and Scripting | 1 | 08-11-2008 10:03 PM |
| Formatting info into columns | straight_edge | Shell Programming and Scripting | 8 | 02-05-2007 10:51 AM |
| Formatting output | illur81 | Shell Programming and Scripting | 3 | 10-13-2005 09:24 AM |
| Text formatting to 132 columns | jmossman | UNIX for Dummies Questions & Answers | 16 | 05-06-2002 08:34 PM |
|
|