文字列と一致し、新しい文字列を追加します。

文字列と一致し、新しい文字列を追加します。

次のファイルがあります。

NbV1Ch01        transdecoder    gene    802292  803490  .       +       .       ID=STRG.1;Name=ORF%20type%3A5prime_partial%20len%3A222%20%28%2B%29%2Cscore%3D55.19%2CXP_009619919.1%7C95.4%7C9.7e-113%2Cperoxidase%7CPF00141.23%7C3.1e-67%2CBaculo_PEP_C%7CPF04513.12%7C0.049%2CBaculo_PEP_C%7CPF04513.12%7C5.7e%2B02
NbV1Ch01        transdecoder    mRNA    802292  803490  .       +       .       ID=STRG.1.1.p1;Parent=STRG.1;Name=ORF%20type%3A5prime_partial%20len%3A222%20%28%2B%29%2Cscore%3D55.19%2CXP_009619919.1%7C95.4%7C9.7e-113%2Cperoxidase%7CPF00141.23%7C3.1e-67%2CBaculo_PEP_C%7CPF04513.12%7C0.049%2CBaculo_PEP_C%7CPF04513.12%7C5.7e%2B02
NbV1Ch01        transdecoder    exon    802292  802491  .       +       .       ID=STRG.1.1.p1.exon1;Parent=STRG.1.1.p1
NbV1Ch01        transdecoder    CDS     802294  802491  .       +       0       ID=cds.STRG.1.1.p1;Parent=STRG.1.1.p1
NbV1Ch01        transdecoder    exon    802781  802946  .       +       .       ID=STRG.1.1.p1.exon2;Parent=STRG.1.1.p1
NbV1Ch01        transdecoder    CDS     802781  802946  .       +       0       ID=cds.STRG.1.1.p1;Parent=STRG.1.1.p1
NbV1Ch01        transdecoder    exon    803048  803490  .       +       .       ID=STRG.1.1.p1.exon3;Parent=STRG.1.1.p1
NbV1Ch01        transdecoder    CDS     803048  803349  .       +       2       ID=cds.STRG.1.1.p1;Parent=STRG.1.1.p1
NbV1Ch01        transdecoder    three_prime_UTR 803350  803490  .       +       .       ID=STRG.1.1.p1.utr3p1;Parent=STRG.1.1.p1

たとえば、このようなものがありますcds.STRG.1.1.p1;Parent=STRG.1.1.p1。どのように変更できますかID=STRG.1.1.p1.cds;Parent=STRG.1.1.p1

事前にありがとう

ベストアンサー1

キス方法:

sed -e 's|cds.|ID=|g' -e 's|p1;|p1.cds;|g' file

つまり、sedを使ってcds.に置き換えID=てからに置き換えp1;ますp1.cds;

出力:

ID=STRG.1.1.p1.cds;Parent=STRG.1.1.p1

これが必要に応じて変更したいファイルにある場合は、以下を使用して内部で編集できます。

sed -i -e 's|cds.|ID=|g' -e 's|p1;|p1.cds;|g' string

おすすめ記事