![]() |
|
|
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 |
| changing month in Mmm format to mm FORMAT | RahulJoshi | Shell Programming and Scripting | 1 | 09-04-2008 03:20 AM |
| Changing display and format of file | wahi80 | UNIX for Dummies Questions & Answers | 1 | 08-02-2008 09:12 PM |
| changing format | shary | Shell Programming and Scripting | 4 | 01-31-2008 05:20 AM |
| changing the format of date | nasirgondal | Post Here to Contact Site Administrators and Moderators | 1 | 06-08-2006 02:37 AM |
| Changing date format | Sabari Nath S | Shell Programming and Scripting | 5 | 12-07-2005 03:38 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi Experts,
Please help me to get the following from script for Unix ENvironment(shell, perl, tr, sed, awk). INPUT FILE: 20K,ME,592971 20K,YOU,2 20K,HE,1244998 50K,YOU,480110 50K,ME,17 50K,HIS,10 50K,HE,1370391 OUTPUT FILE: K,ME,YOU,HE,HIS 20K,592971,2,1244998,0 50K,17,480110,1370391,10 Egarly waiting for response, Thanks a Ton in Advance , ![]() |
|
||||
|
Quote:
This post is to change the format of the output file. Thanks for having a look on it, without solution. It is often the case that the man who can't tell a lie thinks he is the best judge of one. |
|
||||
|
Code:
open FH,"<a.txt";
while(<FH>){
@arr=split(",",$_);
map {tr/\n//d} @arr;
$hash{$arr[0]}->{$arr[1]}=$arr[2];
}
print "K,ME,YOU,HE,HIS\n";
for $key (keys %hash){
print $key,",",($hash{$key}->{ME})?$hash{$key}->{ME}:0,",",($hash{$key}->{YOU})?$hash{$key}->{YOU}:0,",",($hash{$key}->{HE})?$hash{$key}->{HE}:0,",",($hash{$key}->{HIS})?$hash{$key}->{HIS}:0,"\n";
}
|
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|