in reply to Re^10: How to fetch the value of unix command result
in thread How to fetch the value of unix command result
I have changed the field number now, to fetch the fields 3 and 4 instead of only field 3, then combine the field 3 and field 4 and get the count
when i execute below the command in unix prompt
gunzip -c $file|cut -f3,4 -d'|' |sort|uniq -c
i got the below output
2 11 CHECK|KCEHC
My input:
ABC|123|CHECK|KCEHC| DEF|456|CHECK|KCEHC| GHI|789|CHECK|KCEHC| JKL|101|CHECK|KCEHC| ABC|123|CHECK|KCEHC| DEF|456|CHECK|KCEHC| GHI|789|CHECK|KCEHC| JKL|101|CHECK|KCEHC| ABC|123|CHECK|KCEHC| DEF|456|CHECK|KCEHC| GHI|789|CHECK|KCEHC|
I have tired as below, please check the below code
$fh = IO::Zlib->new( "$file", 'rb' ) or die "Zlib failed: $!"; $count{$_}++ for map { ( split /\|/ )[3,4] } <$fh>; print Dumper(%count);
when i executed the script, i got the output as
$VAR1 = ''; $VAR2 = 1; $VAR3 = 'CHECK'; $VAR4 = 11; $VAR5 = 'KCEHC'; $VAR6 = 11; $VAR7 = '';
I am expecting my output as below
CHECK|KCEHC 11
I want to combine the two keys CHECK and KCEHC and assign a value 11. becuase two keys has same value
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^12: How to fetch the value of unix command result
by poj (Abbot) on Jul 01, 2013 at 08:08 UTC |