使用命令行(不是python或perl)使用此模式拆分a

时间:2014-04-10 18:08:26

标签: command-line awk split

我正在寻找一种方法来拆分看起来像这样的文本文件:

[something1, something2, something3]
{ a lot of things....}
{a lot of things...including [something4, ...].}
[something5, something6, something7]
{ a lot of things....}
{a lot of things...including [something8, ...].}
.. a random number of {....} 
[something8, something8, something8]
{ a lot of things....}

分别包含一个实体的文件:

file 1:
[something1, something2, something3]
{ a lot of things....}
{a lot of things...including [something4, ...].}

file 2:
[something5, something6, something7]
{ a lot of things....}
{a lot of things...including [something8, ...].}
.. a random number of {....} 

等等。我不想使用python或perl,我想知道我是否可以使用awk做到这一点?或其他一些命令行工具。分隔符始终是行的开头的“[”,但不在行的中间。

1 个答案:

答案 0 :(得分:0)

您可以像在命令行中使用AWK一样使用perl,使用-e选项:

perl -e 'print "Hello world\n"'

然后,您可以创建一个可以满足您需求的脚本。