awk之match函数
Posted 一周一paper,一周一技术
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了awk之match函数相关的知识,希望对你有一定的参考价值。
格式:match(string,regexp,array) 和string~regexp的作用类似
说明:不依靠$1,2,3。。。来提取特定的列.
没有array的情况下:通过regexp,在string中寻找最左边,最长的substring,返回substring的index位置。
有array的情况下:在regexp中用()将要组成的array的内容按顺序弄好,a[1]代表第一个()的内容,a[2]代表第二个()的内容,以此类推。
echo "gene_type "mrna";gene_name "typ""|awk ‘match($0,/(gene_type).+(".+?");gene_name/,a){print a[1]}‘ gene_type echo "gene_type "mrna";gene_name "typ""|awk ‘match($0,/(gene_type).+("+?");gene_nae/,a){print a[2]}‘ mrna
以上是关于awk之match函数的主要内容,如果未能解决你的问题,请参考以下文章