本文介绍了打印字段'N'到行尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个问题,我在awk的帮助或方向。

I would like to have help or direction on a problem I have in awk.

我有超过5场制表符分隔的文件。我想输出不计首5个字段的字段。

I have a tab-delimited file with more than 5 fields. I want to output the fields excluding the first 5 fields.

你能告诉如何写awk脚本来完成这项任务?

Could you please tell how to write an awk script to accomplish this task?

最佳,
jianfeng.mao

Best,jianfeng.mao

请注意以下几点那种评论:

Do Note the following kind comment:

有在我的文件很多领域。不同的线路具有不同数量的域。每行中的字段的数目是不标准。

There are many fields in my files. Different lines have a different number of fields. The number of fields per line is not standard.

推荐答案

我同意matchew的建议,使用削减:这是这个工作的工具。但是,如果这仅仅是要成为一个更大的 AWK 脚本的一部分,这里是如何做到这一点:

I agree with matchew's suggestion to use cut: it's the right tool for this job. But if this is just going to become a part of a larger awk script, here's how to do it:

awk -F "\t" '{ for (i=6; i<=NF; ++i) $(i-5) = $i; NF = NF-5; print; }

这篇关于打印字段'N'到行尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 00:24