我有文件input.txt中,如下:如何使用cut和awk命令以表格格式提取文本输入?
文件名:test1.v
BUG: bug 102 is fixed by some user
IO_CHANGE: there is no io_change for this version
FEATURE: no feature added
文件名:test2.v
BUG: bug 103 is fixed by some user
also bug 105 is fixed
IO_CHANGE: there is no io_change for this version
FEATURE: yes feature number 3 also feature 23
and feature 34 is added
文件名:test3.v
BUG: bug 104 is fixed by some user
FEATURE: yes feature number 2
IO_CHANGE:
我的问题: - 有时候BUG/FEATURE/IO_CHANGE有一个很长的描述在2行中,或者有时IO_CHANGE中没有任何内容,因此它是空白的。输出文件应该包含所有错误的列表,然后是特征和io_changes。这3种类型可以在输入文件中以任何顺序排列,我需要从文件中找到所有缺陷/功能/ io_changes并列出它们列。
由于事实,你要打印'$ 2'和使用' :'as'FS'没有':'的行将被打印 –
谢谢@Jidder。我在'NF == 1'条件下输入了一个类型。它现在可以正确折叠多行。 – MrFlick