我grep -oP '(?<=%28).*?(?=%29)' f.txt
在下面一行做
chr01_pilon_pilon gmap-gsnap mRNA 55846944 55847057 . + . ID=NbD052382.1.mrna1;Name=NbD052382.1;Note=cytochrome b6/f complex subunit V %28plastid%29 %28NP_054520.1%29;Parent=NbD052382.1.path1;coverage=100.0;identity=100.0;indels=0;matches=114;mismatches=0;unknowns=0
我明白了plastid%29 %28NP_054520.1%29
。怎么可能只得到最后一场比赛NP_054520.1
?
先感谢您
答案1
您可以用贪婪\K
(“保持左侧”)断言替换后向观察:
$ grep -oP '.*%28\K.*?(?=%29)' f.txt
NP_054520.1