bash:替换包含点的字符的第一个实例

bash:替换包含点的字符的第一个实例

我想用选项卡替换“.*_”的第一个实例,如下所示

WP_162009627.1_hypothetical_protein_[Borreliella_burgdorferi]
AAC67153.1_translation_initiation_factor_IF-2_putative_[Borreliella_burgdorferi_B31]
AA_C67154.1_transcription_elongation_protein_NusA_[Borreliella_burgdorferi_B31]
AAC67155.1_conserved_hypothetical_protein_[Borreliella_burgdorferi_B31]
EEH32441.1_hypothetical_protein_BBU29805_0856_[Borreliella_burgdorferi_29805]
AAF07414.1_2.9-7_ORF-C_(plasmid)_[Borreliella_burgdorferi_B31]
AA_F07637.1_BlyB_(plasmid)_[Borreliella_burgdorferi_B31]
AAF07415.2_borrelia_orf-D_family_(plasmid)_[Borreliella_burgdorferi_B31]
AAF_07637.1_BlyB_(plasmid)_[Borreliella_burgdorferi_B31]
AAF07414.1_2.9-7_ORF-C_(plasmid)_[Borreliella_burgdorferi_B31]
PRR_07352.1_hypothetical_protein_CV677_05765_[Borreliella_burgdorferi]
EEG99465.1_conserved_hypothetical_protein_[Borreliella_burgdorferi_94a]

预期结果

WP_162009627.1  hypothetical_protein_[Borreliella_burgdorferi]
AAC67153.1  translation_initiation_factor_IF-2_putative_[Borreliella_burgdorferi_B31]
AA_C67154.1 transcription_elongation_protein_NusA_[Borreliella_burgdorferi_B31]
AAC67155.1  conserved_hypothetical_protein_[Borreliella_burgdorferi_B31]
EEH32441.1  hypothetical_protein_BBU29805_0856_[Borreliella_burgdorferi_29805]
AAF07414.1  2.9-7_ORF-C_(plasmid)_[Borreliella_burgdorferi_B31]
AA_F07637.1 BlyB_(plasmid)_[Borreliella_burgdorferi_B31]
AAF07415.2  borrelia_orf-D_family_(plasmid)_[Borreliella_burgdorferi_B31]
AAF_07637.1 BlyB_(plasmid)_[Borreliella_burgdorferi_B31]
AAF07414.1  2.9-7_ORF-C_(plasmid)_[Borreliella_burgdorferi_B31]
PRR_07352.1 hypothetical_protein_CV677_05765_[Borreliella_burgdorferi]
EEG99465.1  conserved_hypothetical_protein_[Borreliella_burgdorferi_94a]

我尝试了“sed -e 's/\.[1,2]_/\t/'”但它给了我

WP_162009627    hypothetical_protein_[Borreliella_burgdorferi]
AAC67153    translation_initiation_factor_IF-2_putative_[Borreliella_burgdorferi_B31]
AA_C67154   transcription_elongation_protein_NusA_[Borreliella_burgdorferi_B31]
AAC67155    conserved_hypothetical_protein_[Borreliella_burgdorferi_B31]
EEH32441    hypothetical_protein_BBU29805_0856_[Borreliella_burgdorferi_29805]
AAF07414    2.9-7_ORF-C_(plasmid)_[Borreliella_burgdorferi_B31]
AA_F07637   BlyB_(plasmid)_[Borreliella_burgdorferi_B31]
AAF07415    borrelia_orf-D_family_(plasmid)_[Borreliella_burgdorferi_B31]
AAF_07637   BlyB_(plasmid)_[Borreliella_burgdorferi_B31]
AAF07414    2.9-7_ORF-C_(plasmid)_[Borreliella_burgdorferi_B31]
PRR_07352   hypothetical_protein_CV677_05765_[Borreliella_burgdorferi]
EEG99465    conserved_hypothetical_protein_[Borreliella_burgdorferi_94a]

答案1

像这样:

$ sed -E 's/(\.[1,2]+)_/\1\t/' file
WP_162009627.1  hypothetical_protein_[Borreliella_burgdorferi]
AAC67153.1  translation_initiation_factor_IF-2_putative_[Borreliella_burgdorferi_B31]
AA_C67154.1 transcription_elongation_protein_NusA_[Borreliella_burgdorferi_B31]
AAC67155.1  conserved_hypothetical_protein_[Borreliella_burgdorferi_B31]
EEH32441.1  hypothetical_protein_BBU29805_0856_[Borreliella_burgdorferi_29805]
AAF07414.1  2.9-7_ORF-C_(plasmid)_[Borreliella_burgdorferi_B31]
AA_F07637.1 BlyB_(plasmid)_[Borreliella_burgdorferi_B31]
AAF07415.2  borrelia_orf-D_family_(plasmid)_[Borreliella_burgdorferi_B31]
AAF_07637.1 BlyB_(plasmid)_[Borreliella_burgdorferi_B31]
AAF07414.1  2.9-7_ORF-C_(plasmid)_[Borreliella_burgdorferi_B31]
PRR_07352.1 hypothetical_protein_CV677_05765_[Borreliella_burgdorferi]
EEG99465.1  conserved_hypothetical_protein_[Borreliella_burgdorferi_94a]

相关内容