Question: (Closed) Removing text after pattern using sed
0
gravatar for T_18
11 months ago by
T_1840
T_1840 wrote:

Dear all,

I am just new in the world of sed.. Simple question, but struggling now for quit a while with this:

I have a list of gene names:

CYP6k1
CYP4L15
CYP354A5
CYP4d8
CYP354A5
CYP354A14
CYP4c1
CYP354A5
CYP4V2
CYP354A5

I only want to keep "CYP" and the number, so: CYP6, CYP4 etc. I tried to use sed as follows (closest I could get):

sed -E 's/[A-Z]{3}[0-9]+//'

But this is removing exactly the bit that I want to keep and I cannot use 'verbose' in combinaton with sed.

Any help is much appreciated! Thanks!

sed unix • 813 views
ADD COMMENTlink modified 11 months ago by genomax69k • written 11 months ago by T_1840
1
sed 's/^\(CYP[0-9]*\).*/\1/'
ADD REPLYlink modified 11 months ago • written 11 months ago by Pierre Lindenbaum121k

After running above command, you may need to sort and do a uniq @ T_18

ADD REPLYlink modified 11 months ago by RamRS22k • written 11 months ago by cpad011211k

Hello T_18!

We believe that this post does not fit the main topic of this site.

Purely unix question. Please Google/search StackOverflow

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!

ADD REPLYlink written 11 months ago by RamRS22k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 903 users visited in the last hour