views:

23

answers:

1

I have a pov-ray file, which defines a lot of cylinders and spheres. Sometimes these shapes are defined to have "color@", which makes the povray unrenderable. One solution I've found is to delete the offending cylinders and spheres. So a file that contains this text

 cylinder {
<    -0.17623,     0.24511,    -0.27947>, <    -0.15220,     0.22658,    -0.26472>,      0.00716
 texture { colorO }
 }
sphere { 
<    -0.00950,     0.00357,     0.00227>,      0.00716
 texture { color@ }
 }
 cylinder {
<    -0.00950,     0.00357,     0.00227>, <     0.00327,     0.00169,     0.00108>,      0.00716
 texture { color@ }
 }
sphere { 
<     0.15373,     0.00601,     0.18223>,      0.00716
 texture { colorO }
 }

would turn into this text

 cylinder {
<    -0.17623,     0.24511,    -0.27947>, <    -0.15220,     0.22658,    -0.26472>,      0.00716
 texture { colorO }
 }
sphere { 
<     0.15373,     0.00601,     0.18223>,      0.00716
 texture { colorO }
 }

Is there some way to do this replacement with a shell script? Preferably in tcsh. Thanks!

+1  A: 
cat yourFile | egrep -B 2 -A 1 'color[^@].*' | egrep -v -- '^--$'

This should do the trick, providing the example you supplied is exact - i.e. 2 lines before 'color' and 1 line after 'color' are the lines which describe what you need.

Drakosha