首页 > 解决方案 > 用上一行的内容替换文本

问题描述

我有一个文本文件,其中包含以下类型的多个块。

我想用工具的输出替换“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

标签: bash

解决方案


推荐阅读