打印只是awk的某些列 [英] Print just some columns in awk
问题描述
我想知道如何过滤要从一个txt文件编程语言的只是名字。
我已经使用在AWK下面这句话,但我不能得到我想要的:
I was wondering how to filter just the name of the programming language from a txt file. I have used the following sentence in AWK but I cannot get what I want:
($1 ~ /[A-Za-z]*/) && ( ($3 ~ /-/) || ($4 ~ /-/) )
怎么做任何想法?因为你可以看到,有没有正规途径的行写的。
Any ideas of how to do it? Cause as you can see, there is no regular way the lines are written.
在换句话说,我有以下行,但我只是想打印只是编程语言的名称
In other words, I have the following lines but I just want to print just the programming language name
2.PAK - AI language with coroutines. "The 2.PAK Language: Goals and
Description", L.F. Melli, Proc IJCAI 1975.
473L Query - English-like query language for Air Force 473L system. Sammet
1969, p.665. "Headquarters USAF Command and Control System Query
Language", Info Sys Sci, Proc 2nd Congress, Spartan Books 1965, pp.57-76.
3-LISP - Brian Smith. A procedurally reflective dialect of LISP which uses
an infinite tower of interpreters.
我只想过滤,使出现下列行:
I just want to filter and make the following lines appear:
2.PAK
473L Query
3-LISP
编辑:现在会为同一句子工作以下
DML -
1. Data Management Language. Early ALGOL-like language with lists,
graphics, on Honeywell 635.
2. "DML: A Meta-language and System for the Generation of Practical and
Efficient Compilers from Denotational Specifications"
我想我只需要解决一些RS和FS的东西,所以我能得到这个行?
I guess I just have to fix some of the RS and FS stuff so I can get this line?
DML
在此先感谢!
推荐答案
它看起来像 - 可能是一个很好的分离,给出的文件:
It looks like " - " could be a good separator, given the file:
$ cat /tmp/a
2.PAK - AI language with coroutines. "The 2.PAK Language: Goals and
Description", L.F. Melli, Proc IJCAI 1975.
473L Query - English-like query language for Air Force 473L system. Sammet
1969, p.665. "Headquarters USAF Command and Control System Query
Language", Info Sys Sci, Proc 2nd Congress, Spartan Books 1965, pp.57-76.
3-LISP - Brian Smith. A procedurally reflective dialect of LISP which uses
an infinite tower of interpreters.
您可以使用以下内容:
$ awk -F ' - ' '/ - /{ print $1 }' /tmp/a
2.PAK
473L Query
3-LISP
$
这篇关于打印只是awk的某些列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!