小编Hub*_*bbs的帖子

Bash 通过多字符分隔符将多行字符串拆分为数组

我在这里搜索了类似的主题,但大多数问题都包含单字符分隔符。

我有这个文本样本:

Some text here,
continuing on next lineDELIMITERSecond chunk of text
which may as well continue on next lineDELIMITERFinal chunk
Run Code Online (Sandbox Code Playgroud)

所需的输出是一个列表 ( extracted=()),其中包含:

  1. Some text here, continuing on next line
  2. Second chunk of text which may as well continue on next line
  3. Final chunk

从示例中可以看出,“DELIMITER”用作分割分隔符。

我在 SO 上尝试了许多示例,包括 awk、替换等。

bash shell awk

3
推荐指数
1
解决办法
2304
查看次数

标签 统计

awk ×1

bash ×1

shell ×1