我正在尝试在批处理控制台中使用 sed 替换一些字符串。我的输入包含在一个文件中,其中包含以下几行:
$ head qiimetax_sorted.txt
A61579.1.1437
D_0__Bacteria;D_1__Thermotogae;D_2__Thermotogae;D_3__Thermotogales;
D_4__Fervidobacteriaceae;D_5__Fervidobacterium;Ambiguous_taxa;D_7__;
D_8__;D_9__;D_10__;D_11__;D_12__;D_13__;D_14__
AAAA02020712.626.2096
D_0__Bacteria;D_1__Proteobacteria;D_2__Alphaproteobacteria;D_3__Rhizobiales;
D_4__Bradyrhizobiaceae;D_5__uncultured;D_6__Oryza sativa
Indica Group (long-grained rice);D_7__;D_8__;D_9__;D_10__;D_11__;D_12__;
D_13__;D_14__
现在我试图用这个 sed 命令删除名称之前的 'D_number__' 字符串,它没有替换任何东西:
sed -r 's/D_\d+__//g' qiimetax_sorted.txt > qiimesed.txt
知道哪个是问题吗?谢谢!
您的正则表达式语法类似于 perl。
所以如果你想保留它:
perl -pe 's/D_\d+__//g' qiimetax_sorted.txt > qiimesed.tx
或使用sed:
sed -r 's/D_[0-9]+__//g' qiimetax_sorted.txt > qiimesed.tx
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句