rajsai28 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to fetch the value of unix command result
by rjt (Curate) on Jun 30, 2013 at 11:00 UTC | |
by rajsai28 (Novice) on Jun 30, 2013 at 11:46 UTC | |
by rjt (Curate) on Jun 30, 2013 at 12:22 UTC | |
by rajsai28 (Novice) on Jun 30, 2013 at 12:01 UTC | |
by rjt (Curate) on Jun 30, 2013 at 12:45 UTC | |
by rajsai28 (Novice) on Jun 30, 2013 at 13:07 UTC | |
|