0
我想在批處理控制檯中使用sed替換一些字符串。我的輸入包括在文件中有這樣的詩句:在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
任何想法是哪個問題? 謝謝!
也見[爲什麼在X,但不以y我的正則表達式的工作?](HTTPS:/ /unix.stackexchange.com/questions/119905/why-does-my-regular-expression-work-in-x-but-not-in-y) – Sundeep