新列添加到文件 [英] Add a new column to the file

查看:105
本文介绍了新列添加到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何添加一个新列使用awk codeS的文件?

original.file

  F1 F2 F3 ..F10

添加到F11 original.file

  F1 F2 F3 ..F10 F11


解决方案

尝试:

 的awk'BEGIN {函数getline to_add< F3} {打印$ 0 to_add}'F

读取列从文件F3添加和可变to_add保存它。后它添加的列文件f的每一行。

HTH克里斯

How can I add a new column to a file with awk codes?

original.file

F1 F2 F3 ..F10 

add F11 to original.file

F1 F2 F3 ..F10 F11

解决方案

try:

awk 'BEGIN{getline to_add < "f3"}{print $0,to_add}' f

Reads the column to add from file "f3" and saves it in the variable to_add. After that it adds the column to each line of file f.

HTH Chris

这篇关于新列添加到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆