それは非常に簡単perlです:
perl -e 'local $/; $_ = <>; print $1."------\n" while (/(typedef struct {.*?}.*?\n)/msg);'
例:
$ cat /tmp/1.txt
typedef struct {
...
...
...
} structure1
hello
typedef struct {
...
...
...
} structure2
bye
$ cat /tmp/1.txt | perl -e 'local $/; $_ = <>; print $1."------\n" while (/(typedef struct {.*?}.*?\n)/msg);'
typedef struct {
...
...
...
} structure1
------
typedef struct {
...
...
...
} structure2
------
で区切られた確立されたブロック---------。
構造体の名前のみを取得する場合は、正規表現の別の部分をグループ化する必要があります(必要な部分を使用してグループ化する())。
$ cat /tmp/1.txt | perl -e 'local $/; $_ = <>; print $1."\n" while (/typedef struct {.*?}\s*(.*?)\n/msg);'
structure1
structure2
ご覧のとおり、正規表現を少し変更しました。
/typedef struct {.*?}\s*(.*?)\n/
後に続く文字列の部分は}、グループにキャプチャされ$1ます。