grep - block with start & end text

2016-03-19 Thread Prashant Thorat
Hi All,

Can you please help me to grep below 'block of text' from my file ? this
blocks occurs number of time & I want to grep all in between lines of this
block -

first line is having - retr_test asm1
& 4th line is having only - END

so I want to grep all four lines with above match .

Thanks in advance,
Prashant


Re: grep - block with start & end text

2016-03-18 Thread Prashant Thorat
Hi All...Thanks a lot  for help..!!!

On Sat, Mar 19, 2016 at 1:22 AM, Scott Hall  wrote:

> Thanks Andrew.
>
> Your article explained what I did not have the words for.  It was very
> well written.
>
> Scott
>
> On Fri, Mar 18, 2016 at 1:23 PM Andrew Solomon  wrote:
>
>> And to understand Scott's easy to write, hard to understand approach:
>>
>> http://blog.geekuni.com/2016/03/perl-flip-flop.html
>>
>> Andrew
>>
>> On Fri, Mar 18, 2016 at 3:50 PM, Scott Hall 
>> wrote:
>>
>>>
>>>
>>> On Fri, Mar 18, 2016 at 9:40 AM Prashant Thorat <
>>> thorat.prash...@gmail.com> wrote:
>>>
>>>> Hi All,
>>>>
>>>> Can you please help me to grep below 'block of text' from my file ?
>>>> this blocks occurs number of time & I want to grep all in between lines of
>>>> this block -
>>>>
>>>> first line is having - retr_test asm1
>>>> & 4th line is having only - END
>>>>
>>>> so I want to grep all four lines with above match .
>>>>
>>>>
>>> If you are looking for a command line that works like grep:
>>>
>>> perl -lne 'print if /retr_test asm1/ .. /END/;' input_file
>>>
>>> http://perldoc.perl.org/perlop.html#Range-Operators
>>>
>>> Best Regards,
>>>
>>> Scott
>>>
>>>
>>>> Thanks in advance,
>>>> Prashant
>>>>
>>>>
>>>>
>>
>>
>> --
>> Andrew Solomon
>>
>> Mentor@Geekuni http://geekuni.com/
>> http://www.linkedin.com/in/asolomon
>>
>


Multi line file handling

2015-10-19 Thread Prashant Thorat
Hi All,

I have a file with multiple lines ,I want to assign all content to variable
& then want to work on it.
Like want to match pattern /window/ from it.
how can it is possible ?
for example -

open ( F1 ,"file.txt") || die "$!";

$a=;

if (/window/i){print
"it is present\n";
}