用awk分隔连接的列 [英] Separating joined columns with awk

查看:79
本文介绍了用awk分隔连接的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据文件,如下所示:

I have a data file which looks like the following:

0.00000-130250.92921  28880.20200-159131.13121    301.58706
0.05000-130250.73120  28156.69202-158407.42322    294.03167
0.10000-130250.79137  28237.16138-158487.95275    294.87198
0.15000-130250.81209  28168.63042-158419.44250    294.15634
0.20000-130250.82418  28149.57611-158400.40029    293.95736
0.25000-130250.88438  28069.57135-158320.45573    293.12189
0.30000-130251.06059  28071.30576-158322.36635    293.14000
0.35000-130250.96639  28084.46351-158335.42990    293.27741

如您所见,一些以-"符号开头的列是 加入上一个,例如:0.35000-130250.96639 这应该是0.35000和-130250.96639.我可以分开 VIM专栏,但我想知道是否有可能做到这一点 使用AWK.

as you can see some of the columns which start with "-" sign are joined to the previous one, for instance: 0.35000-130250.96639 this should be 0.35000 and -130250.96639. I can separate the columns with VIM but I wanted to know if it is possible to do that with AWK.

谢谢.

推荐答案

您可以使用sed:用空格和-替换每个-:

You can use sed: replace each - with a space and -:

sed -e 's/-/ -/g' input > output

/g表示全局,即替换每行中的所有匹配项,而不仅仅是第一行.

The /g means globally, i.e. it replaces all occurrences on each line, not just the first one.

这篇关于用awk分隔连接的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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