Afficher un message
Vieux 19/08/2006, 08h42   #5
Xicheng Jia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: In sed, how do you delete just the first matching line in a block of lines?

Xicheng Jia wrote:
> Dave S. wrote:
> > Xicheng,
> >
> > Your solution did not work when I incorporated it into my original
> > script, but it DID work as a separate script so I'm putting it in a
> > separate script that makes a second pass on the output.

>
> Maybe you can try this:
>
> sed '/switch/,/case/!{/case\|default/i\
> \tbreak;
> }'
>
> or use perl:


or probably:

perl -pe '
s/(\s*)(case|default)/$1\tbreak;\n$1$2/
if not /switch/../case/'

awk '
/switch/,/case/ { print; next }
/case|default/ { print "\tbreak;" }1'

Xicheng

  Réponse avec citation
 
Page generated in 0,04825 seconds with 9 queries