Regular expression not matching correctly in sed command

ALG

I am trying to replace some character strings using sed in batch console. My input consists in a file with lines like these:

$ 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__

Now I'm trying to erase the 'D_number__' string before the names with this sed command and it is not replacing anything:

sed -r 's/D_\d+__//g' qiimetax_sorted.txt > qiimesed.txt

Any idea of which is the problem? Thanks!

Gilles Quenot

Your regex syntax is perl like.

So if you want to keep it :

perl -pe 's/D_\d+__//g' qiimetax_sorted.txt > qiimesed.tx

or with :

sed -r 's/D_[0-9]+__//g' qiimetax_sorted.txt > qiimesed.tx

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related