Hi Experts,

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


In reply to Re^11: How to fetch the value of unix command result by rajsai28
in thread How to fetch the value of unix command result by rajsai28

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.