Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex sed命令中的正则表达式不正确匹配_Regex_Bash_Unix_Sed - Fatal编程技术网

Regex sed命令中的正则表达式不正确匹配

Regex sed命令中的正则表达式不正确匹配,regex,bash,unix,sed,Regex,Bash,Unix,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_

我试图在批处理控制台中使用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_uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu

sed -r 's/D_\d+__//g' qiimetax_sorted.txt > qiimesed.txt
你知道问题出在哪吗?
谢谢

您的正则表达式语法类似于perl

因此,如果您想保留它:

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


您的正则表达式语法类似于perl

因此,如果您想保留它:

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


建议:使用
-E
而不是
-r
。。GNU sed支持这两个版本,据我所知,其他一些sed版本现在支持
-E
。建议:使用
-E
而不是
-r
。。GNU sed同时支持这两个版本,据我所知,其他一些sed版本现在支持
-E
。另请参见