我想知道如何解析如下所示的段落:
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
And many other lines with text that I do not need
* * * * * * *
Autolisp - Dialect of LISP used by the Autocad CAD package, Autodesk,
Sausalito, CA.
CPL -
1. Combined Programming Language. U Cambridge and U London. A very
complex language, syntactically based on ALGOL-60, with a pure functional
subset.
Modula-3* - Incoprporation of Modula-2* ideas into Modula-3. "Modula-3*:
所以我可以从 awk 语句中得到以下退出:
Autolisp
CPL
Modula-3*
我尝试了以下句子,因为我要过滤的文件很大。它是迄今为止所有现有编程语言的列表,但基本上所有行都遵循与上面相同的模式
到目前为止我用过的句子:
BEGIN{$0 !~ /^ / && NF == 2 && $2 == "-"} { print $1 }
BEGIN{RS=""; ORS="\n\n"; FS=OFS="\n"} /^FLIP -/{print $1,$3}
BEGIN{RS=""; FS=OFS="\n"} {print $1 NF-1}
BEGIN{NF == 2 && $2 == "-" } { print $1 }
BEGIN { RS = "" } { print $1 }
到目前为止对我有用的句子是:
BEGIN { RS = "\n\n"; FS = " - " }
{ print $1 }
awk -F " - " "/ - /{ print $1 }" file.txt
但它仍然会打印或跳过我需要/不需要的行。
感谢您的帮助和回复!我已经打破了几天的头,因为我是 AWK 编程的菜鸟