好的,我有一些文字:
=== Blah 1 ===
::Junk I wish: 2 Ignore <br/>
::More Junk: 1.2-2.7 <br/>
::ABC: [http://www.google.com (STUFF/I/Want)]<br/>
::More2: Ignore<br/>
::More Stuf 2 Ignore: N/A<br/>
=== Blah 2 ===
::Junk I wish: More 2 Ignore <br/>
::More Junk: 1.2-2.7 <br/>
::ABC: [http://www.google.com (Other/STUFF/I/Want)]<br/>
::More2: More Ignore<br/>
::More Stuf 2 Ignore: More N/A<br/>
我想输出:
Blah 1, (STUFF/I/Want)
Blah 2, (Other/STUFF/I/Want)
我已经想出了如何抓住我想要的部分线条:
gawk '/===/ {print } /ABC/ {print $3}' file_name
这将输出以下内容:
=== Blah 1 ===
(STUFF/I/Want)]<br/>
=== Blah 2 ===
(Other/STUFF/I/Want)]<br/>
我不明白的是如何剥离我不想要的其他字符,并将其放在一行中。