更新时间:2023-09-01 19:59:28
要打印整个单词,您需要-f 1
,而不是-c 1
.而且由于默认的字段定界符是TAB而不是SPACE,因此您需要使用-d
选项.
To print a whole word, you want -f 1
, not -c 1
. And since the default field delimiter is TAB rather than SPACE, you need to use the -d
option.
cut -d' ' -f1 filename
要打印使用cut
的AFAIK不可能完成的最后两个单词,因为它只能从行的开头开始计数.使用awk
代替:
To print the last two words not possible with cut
, AFAIK, because it can only count from the beginning of the line. Use awk
instead:
awk '{print $(NF-1), $NF;}' filename