![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to changes rows to columns in a file | oracle123 | Shell Programming and Scripting | 4 | 07-31-2008 04:38 AM |
| How to convert a single column into several rows and columns? | ashton_smith | UNIX for Dummies Questions & Answers | 5 | 05-24-2008 04:44 PM |
| shell script required to convert rows to columns | suresh3566 | Shell Programming and Scripting | 2 | 05-07-2008 05:25 AM |
| deleting rows & columns form a csv file | code19 | Shell Programming and Scripting | 2 | 03-13-2008 10:06 AM |
| Columns to rows | mgirinath | Shell Programming and Scripting | 16 | 11-29-2007 07:03 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
looking to do the following...
What the data looks like Code:
server1 02/01/2008 groups 10 server1 03/01/2008 groups 15 server1 04/01/2008 groups 20 server2 02/01/2008 users 50 server2 03/01/2008 users 75 server2 04/01/2008 users 100 server2 04/01/2008 users 125 What I would like the data to look like Code:
server1 groups 15 20 seerver2 users 100 125 JD |
|
||||
|
perl:
Code:
open(FH,"<filename");
while(<FH>){
@arr=split(" ",$_);
$t=sprintf("%s %s",$arr[0],$arr[2]);
$hash{$t}=sprintf("%s %s",$hash{$t},$arr[3]);
}
close(FH);
for $key (keys %hash){
@temp=split(" ",$hash{$key});
print $key," ",$temp[$#temp-1]," ",$temp[$#temp],"\n";
}
|
![]() |
| Bookmarks |
| Tags |
| awk reformat parse |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|