Sed problem to change names
Hi,
I want to use 'Sed' to change the names in both sequences and annotation files. Such as change
scaffold1_size2426064 exon
scaffold2_size1571916 exon
scaffold3_size1509833 gene
scaffold4_size1453470
scaffold5_size1243770
scaffold6_size1253778
scaffold7_size1219719
scaffold8_size1223566
scaffold9_size1121364
scaffold10_size1060754
...... to
scaffold1 exon
scaffold2 exon
scaffold3 gene
scaffold4
scaffold5
scaffold6
scaffold7
scaffold8
scaffold9
scaffold10
Delete '_'and the following things. I tried sed 's/_size*//g' file but it didn't work. And I don't want to use blank to instead those things in my annotation file. Does anybody know how to do this? Thanks.
Zhang
• 845 views
•
link
2 answers
sed 's/_[^ ]*//' input.txt
• 0 views
•
link
You can try sed 's/_size.*[0-9]//g'
$ echo 'scaffold1_size2426064 exon' | sed 's/_size.*[0-9]//g'
scaffold1 exon
• 0 views
•
link
Log in to answer this question.
How to delete the rest of each line after a certain pattern or a string in a file?
Return only the portion of a line after a matching pattern
Delete part of a string after a match, but not the line using sed
P.S: If you spend sometime on google searching for this basic problems, it is very likely you will find a solution.
Hello HZZ0036!
We believe that this post does not fit the main topic of this site.
This is just Unix. Search StackOverflow please.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!