Hi I need to add double quotes in a pattern in 300k lines. I'm trying to use sed and I read multiple inquiries here and other sources, but I can't seem to understand its syntax.
I have:
chr1 StringTie exon 191964 192299 1000 - . gene_id MSTRG.201; transcript_id MSTRG.201.53; exon_number 2;
chrY StringTie exon 26420508 26420531 1000 + . gene_id MSTRG.49889; transcript_id MSTRG.49889.11; exon_number 1;
And I need to have:
chr1 StringTie exon 191964 192299 1000 - . gene_id "MSTRG.201"; transcript_id "MSTRG.201.53"; exon_number 2;
chrY StringTie exon 26420508 26420531 1000 + . gene_id "MSTRG.49889"; transcript_id "MSTRG.49889.11"; exon_number 1;
I'm using sed as follows:
sed 's/MSTRG./"MSTRG."/g' filename
But I can only get:
chr1 StringTie exon 191964 192299 1000 - . gene_id "MSTRG."201; transcript_id "MSTRG."201.53; exon_number 2;
chrY StringTie exon 26420508 26420531 1000 + . gene_id "MSTRG."49889; transcript_id "MSTRG."49889.11; exon_number 1;
I've tried:
sed -Ei 's|MSTRG[[:digit:]]+|"&"|g' filename
sed 's/M/"M/; s/$/"/' filename
sed 's/MSTRG.[[:digit:]]+/"MSTRG.[[:digit:]]+"/g' filename
But none of these will work.
I was wondering if I could use awk, but I don't have any skills in this language.
Any help, please?
Thanks in advance.