Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 04 Jan 2011 14:12:23 +0100
From:      Patrick Bihan-Faou <patrick.bihan-faou@teambox.fr>
To:        freebsd-questions@freebsd.org
Subject:   Re: a perl question
Message-ID:  <4D231CB7.2060902@teambox.fr>
In-Reply-To: <AANLkTinEksoXQAA4ZAziE59h%2BLRTxSgSy2WZy6UaQne%2B@mail.gmail.com>
References:  <117654.42578.qm@web121409.mail.ne1.yahoo.com> <AANLkTinEksoXQAA4ZAziE59h%2BLRTxSgSy2WZy6UaQne%2B@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Le 04/01/2011 14:06, krad a écrit :
> On 4 January 2011 10:32, S Mathias<smathias1972@yahoo.com>  wrote:
>
>> cat asdf.txt
>> bla-bla
>> bla-bla
>> bla[XYZ]
>> importantthing
>> another important thing
>> [/XYZ]
>> bla-bla
>> bla-bla
>> [XYZ]
>> yet another thing
>> hello!
>> [/XYZ]
>> bla-bla
>> etc.
>> $ SOMEPERLMAGIC asdf.txt>  output.txt
>> $ cat output.txt
>> importantthing
>> another important thing
>> yet another thing
>> hello!
>>
>>
>> how can i sovle this question? what is SOMEPERLMAGIC? are there any perl
>> gurus, that have a little spare time?
>>
>> Thank you! :\
>>
>>
>>
>> _______________________________________________
>> freebsd-questions@freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to "
>> freebsd-questions-unsubscribe@freebsd.org"
>>
>
> doesnt need to be perl either
>
> cat asdf.txt | awk 'BEGIN {a=0} { if ( $0 ~ /\[XYZ\]/ ) a=1;  if ( $0 ~
> /\[\/XYZ\]/ ) a=0; if ( a == 1) print $0}'
>
> or something close to it

Simpler yet

cat asdf.txt | grep -v XYZ | grep -v bla

Patrick.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D231CB7.2060902>