我有一个这样的文件,我只想从文件中获取 EC 编号。
5'-nucleotidase SurE (EC 3.1.3.5)
L-aspartate oxidase (EC 1.4.3.16)
Nicotinamide-nucleotide adenylyltransferase, NadM family (EC 2.7.7.1) @ Nicotinate-nucleotide adenylyltransferase, NadM family (EC 2.7.7.18)
Nicotinamidase (EC 3.5.1.19)
Quinolinate phosphoribosyltransferase [decarboxylating]
NAD synthetase (EC 6.3.1.5) / Glutamine amidotransferase chain of NAD synthetase
4'-phosphopantetheinyl transferase (EC 2.7.8.-)
输出应该是这样的:
(EC 3.1.3.5)
(EC 1.4.3.16)
(EC 2.7.7.1)
(EC 2.7.7.18)
(EC 3.5.1.19)
(EC 6.3.1.5)
(EC 2.7.8.-)
答案1
简单地与grep
:
grep -o '(EC [^)]*)' file
[^)]*
- 匹配除右括号之外的所有字符)
输出:
(EC 3.1.3.5)
(EC 1.4.3.16)
(EC 2.7.7.1)
(EC 2.7.7.18)
(EC 3.5.1.19)
(EC 6.3.1.5)
(EC 2.7.8.-)
答案2
sed -n 's/^\(.*\)\((EC[^)]*)\).*$/\2/p'
和awk
有趣的版本:
awk -F'\\(EC|\\)' 'NF==3 { print "(EC" $2 ")" }'