a perl question

Patrick Bihan-Faou patrick.bihan-faou at teambox.fr
Tue Jan 4 13:29:29 UTC 2011


Le 04/01/2011 14:06, krad a écrit :
> On 4 January 2011 10:32, S Mathias<smathias1972 at 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 at freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to "
>> freebsd-questions-unsubscribe at 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.


More information about the freebsd-questions mailing list