Hi Experts,
I am executing unix command 'gunzip -c test.txt.gz |cut -f3 -d'|'|sort|uniq -c' and stroing the value in a variable, the zip file
contains records as shown below:
ABC|123|CHECK|1|
DEF|456|CHECK|1|
GHI|789|CHECK|1|
JKL|101|KCEHC|2|
I have used the code as shown below, i am executing the unix commands and storing the value in a variable and from the results i am fetching only numeric value
my $r = `gunzip -c test.txt.gz|cut -f3 -d'|'|sort|uniq -c`;
my $c = substr( $r, 6, -1 );
gives me this output:
3 CHECK
1 KCEHC
I am trying to fetch the number 3 from 3 CHECK and 1 from 1 KCEHC,i want store the numbers in a variable separately
I also to grep the CHECK - $r = grep /CHECK/, $r, it returns a 1
Experts any help on this, thanks and regards
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.