Frits has asked for the wisdom of the Perl Monks concerning the following question:
Dear All, I'm not a very strong perl programmer but need to grep data from a large file where I have multiple outputs. Used the following example in ggrep to get my correct output:
cat file.large | ggrep country | ggrep city1 | ggrep street1 | ggrep -v name1Horrilbe, I know.... but need to get the value of name2 only as output. File text looks sort of:
Country City Street1 number1 name1 Country City1 Street1 number1 name2 Country City1 Street1 number2 name3 Country City1 Street2 number1 name4 Country City1 Street2 number1 name5
The output of the info in the 2nd line and going into $myoutput1 as:
Country City Street1 number1 name2The last output required is "$thenameis" will just be name2 from the file. But this can be done with
$thenameis = $myoutput1[4]; ##This should be correct..PS this grep will be in a foreach loop. Any ideas.. thank you
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need to multi grep and grep exclude in perl.
by Discipulus (Canon) on Feb 23, 2016 at 08:53 UTC | |
|
Re: Need to multi grep and grep exclude in perl.
by kcott (Archbishop) on Feb 23, 2016 at 15:45 UTC | |
|
Re: Need to multi grep and grep exclude in perl.
by Random_Walk (Prior) on Feb 23, 2016 at 08:55 UTC | |
|
Re: Need to multi grep and grep exclude in perl.
by perlfan (Parson) on Feb 23, 2016 at 17:10 UTC | |
by FreeBeerReekingMonk (Deacon) on Feb 23, 2016 at 21:09 UTC | |
|
Re: Need to multi grep and grep exclude in perl.
by FreeBeerReekingMonk (Deacon) on Feb 23, 2016 at 18:39 UTC | |
|
Re: Need to multi grep and grep exclude in perl.
by Anonymous Monk on Feb 24, 2016 at 11:12 UTC | |
by Frits (Novice) on Feb 24, 2016 at 11:19 UTC |