1 . Hello World . 51.4 . This is a text . 200
2 . Another line . 16.4 . Some more words . 600
Hello World . 2 . This is a text . 4
Another line . 2 . Some more words . 3
输出是第2列和第4列,它们的字数
我已经
了awk '{print $2, "\t", NF}' > output.tsv
但不知道如何在单个命令中为多个列执行此操作
答案 0 :(得分:1)
awk
救援!
awk 'BEGIN {FS=OFS="\t"}
{print $2,split($2,x," +"),$4,split($4,x," +")}' file
Hello World 2 This is a text 4
Another line 2 Some more words 3