删除 povray 文件中带有内部标志的多行文本块

发布于 2024-08-31 22:29:53 字数 939 浏览 2 评论 0原文

我有一个 pov-ray 文件,它定义了很多圆柱体和球体。有时,这些形状被定义为具有“color@”,这使得 povray 无法渲染。我发现的一种解决方案是删除有问题的圆柱体和球体。因此,包含此文本的文件

 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 }
 }

将变成此文本

 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 }
 }

有没有某种方法可以使用 shell 脚本进行此替换?最好在 tcsh 中。谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沧桑㈠ 2024-09-07 22:29:53
cat yourFile | egrep -B 2 -A 1 'color[^@].*' | egrep -v -- '^--

这应该可以解决问题,前提是您提供的示例是准确的 - 即“颜色”之前的 2 行和“颜色”之后的 1 行是描述您需要的行。

这应该可以解决问题,前提是您提供的示例是准确的 - 即“颜色”之前的 2 行和“颜色”之后的 1 行是描述您需要的行。

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文