bash - 用上一行的内容替换文本
问题描述
我有一个文本文件,其中包含以下类型的多个块。
我想用工具的输出替换“replaceme”,该工具将“someword CODE1”作为输入(和“someotherword CODE2”等)。我可以将该输出放在一个变量中(如果需要,也可以放在数组中)。它应该在 bash 中完成。
有什么建议么?
Tag: CODE1 (1)
*This: someword CODE1
Some message that may contain all kinds of characters
/path/to/file,143|25
replaceme
Tag: CODE2 (5)
*That: someotherword CODE2
Some other message that may contain all kinds of characters
/path/to/anotherfile,110|30
replaceme
解决方案
推荐阅读
- node.js - 打字稿版本与节点版本
- routing - .net核心路由到基于当前域名的剃须刀页面区域?
- jira - 如何将组件添加到 Jira 项目?
- r - 向“as.matrix”显式提供 nrow 和 ncol 不会创建维度
- java - 反序列化似乎不尊重@JsonIgnore
- reactjs - 带有样式组件和 CRUD 的文件结构
- c - Called object type 'void' is not a function or function pointer
- pdf - 为什么使用 ImageMagick/Ghostscript 将此 PDF 转换为图像后缺少文本?
- python - 停止失控递归,使 Python 函数正常工作
- swift - Scanning Real-World Object and generating 3D Mesh from it