我正在尝试将 2 个功能合并到我的awk
命令中。我想要tolower
第 2 列中 Col1 中的信息(因此 Col1 中的信息将是 2 cols 的值 - Col1 和 Col2,其中的值在lower
Col2 中),我想从1-N开始和结束我拥有的某些标记的开始。
数据(制表符分隔)当前如下所示:
<s>
He PRP -
could MD -
tell VB -
she PRP -
was VBD -
teasing VBG -
him PRP -
. . .
</s>
<s>
He PRP -
kept VBD -
his PRP$ -
eyes NNS -
closed VBD -
, , -
but CC -
he PRP -
could MD -
feel VB -
himself PRP -
smiling VBG -
. . .
</s>
理想的输出是这样的:
<s>
He he PRP 1
could could MD 2
tell tell VB 3
she she PRP 4
was was VBD 5
teasing teasing VBG 6
him him PRP 7
. . . 8
</s>
<s>
He he PRP 1-
kept kept VBD 2
his his PRP$ 3
eyes eyes NNS 4
closed closed VBD 5
, , , 6
but but CC 7
he he PRP 8
could could MD 9
feel feel VB 10
himself himself PRP 11
smiling smiling VBG 12
. . . 13
</s>
awk
我正在尝试但不起作用的两步是:
第1步:
awk '!NF{$0=x}1' input | awk '{$1=$1; print "<s>\n" $0 "\t.\n</s>"}' RS= FS='\n' OFS='\t-\n' > output
这里,不知道怎么把“-”变成计数器
和第2步(直接给我一个错误):
awk '{print $1 "\t" '$1 = tolower($1)' "\t" $2 "\t" $3}' input > output
任何建议1.关于如何解决lower和counter和2.是否可以将这两个步骤结合起来?
先感谢您