AWK:访问捕获从线路图组 [英] awk: access captured group from line pattern

查看:229
本文介绍了AWK:访问捕获从线路图组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个awk命令

If I have an awk command

pattern { ... }

和模式使用捕获组,我怎么能访问该块,捕获?字符串

and pattern uses a capturing group, how can I access the string so captured in the block?

推荐答案

这是一个漫步的记忆里......

That was a stroll down memory lane...

我AWK被Perl很久以前更换。

I replaced awk by perl a long time ago.

显然,AWK经常EX pression发动机没有捕捉到它的团体。

Apparently the AWK regular expression engine does not capture its groups.

您可以考虑使用类似:

perl -n -e'/test(\d+)/ && print $1'

-n标志导致Perl来遍历诸如awk每行呢。

the -n flag causes perl to loop over every line like awk does.

这篇关于AWK:访问捕获从线路图组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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