문자열과 일치하고 새 문자열을 추가합니다.

문자열과 일치하고 새 문자열을 추가합니다.

다음 파일이 있습니다.

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

관련 정보