SED替代背部引用不工作 [英] Sed substitution with back reference not working

查看:204
本文介绍了SED替代背部引用不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到的输出从一个程序作为制表符分隔值,其中我试图获得第二只使用SED。我目前使用的:

I receive output from a program as tab separated values, of which I am trying to obtain the second only using sed. I am currently using this:

sed -r -e "s/(^[^\t]+\t)([^\t]+\t)(.*$)/\2/"

然而,它似乎并没有找到匹配。我在尝试过 rubular 是它确实给我我想要的比赛。

However it does not seem to find matches. I have tried it in rubular were it does give me the match I want.

在这里输入的形象描述

推荐答案

有是选择从文本文件称为切列一个专门的工具:

There is a specialized tool for selecting columns from text files called cut:

cut -f2 file

下面我们指示它仅选择第二列,请参阅手册页了解更多信息。 Tab是默认列分隔符。

Here we instruct it to select only the second column, see the manpage for more information. Tab is the default column separator.

这篇关于SED替代背部引用不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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