 |
 |
sed help!!!
|
 |
|
 |
|
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
I'm new to regular expression thing and could use some help using sed. I'm trying to remove some numbers from a string of text (DNA sequence, actually).
I've tried this command:
% sed 's/[0-9]//g' file-name
but it didn't seem to have any effect. Here's my text sequence if that helps:
GCAAAACTCCAATGAAGTCAGAGCCCCCTACTCGCCGCCGCGGCCAGGCC CCCCAACATG61GACTGTCT^MCTGTATAGTGACAACCAAG$
AGTATGAGGAGATCACATTGGAAAGGGG^MTAACTCAGGTCTGGGCTTCA GCATCGCAGGT301GGCACCGACAACCCACACATCGGTGAC$
TCCATCGTTCGCCTCTACGTCATGCGCCGGAAACCCCCAGCTGAGAAGAT CATAGAG^MATC541AAGCTTATCAAAGGGCCTAAAGGACT$
GATGTCATGCATGAG^MGACGCCGTGGCAGCCCTGAAGAACACATATGAC GTTGTGTACCTA781AAGGTGGCCAAGCCCAGCAATG^MCC$
1CTAGGGGAGGAAGATATTCCCCGGGAACCAAGGCGGATCGTGA^MTCCA TCGGGGCTCCACC1021GGCCTGGGCTTCAACATTGTGGGC$
C1^M201GCGGGTCAGACGGTCACGATCATCGCTCAGTATAAACCAGAAG AGTATAGCCGATTCGAG1261GCC^MAAGATCCATGATCTT$
CTTCAT1441GTAATTGACGCCAGCGACGAA^MGAGTGGTGGCAAGCGCG GCGGGTCCACTCTGACAGTGAG1501ACCGATGACATTGGC$
TCATCCTTGGG1681CCTACCAAAGACCGTGCCAACGATGATCTTCTCTC CGAGTTCCCC^MGACAAGTTTGGATCC1741TGTGTCCCTC$
CGAGAGGTAGCAGAG192^M1CAGGGGAAGCACTGCATCCTTGATGTCTC AGCCAATGCCGTGCGGCGGCTGCAGGCGGCC1981CACCT^$
ACAGCTTTGAAGAGATCTAT2161CACAAAGTGAAACGTGTCATCGA^MA GACCTCTCAGGCCCCTACATCTGGGTCCCAGCCCGA2221G$
I'd also like to get rid of the $ and ^, but I figure that should be easy if I can get the numbers out.
thanks!
kman
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
I have no idea what that command you tried was, but couldn't you do what you want in TextEdit with search-and-replace?
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
Originally posted by wataru:
I have no idea what that command you tried was, but couldn't you do what you want in TextEdit with search-and-replace?
Not really. Not nearly as easily, at any rate, giventhat TextEdit doesn't support regular expressions in its search and replace.
But there's another reason why he might want to use the Terminal: it's easier to integrate this into other applications than many search-and-replace GUI solutions. The idea is to use the sed language (which is very powerful for working with streams of bytes) in conjunction with other applications.
Unfortunately, I don't know sed. But I know this belongs in the Unix forum. You're more likely to find people who know sed there.
|
|
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Jan 2000
Status:
Offline
|
|
You might want to put a -e before the expression, e.g.:
sed -e 's/[0-9]//g' filename
I would think both ways would work though. They both do on Solaris. Are you using a file with Mac or Unix style eols? Maybe sed doesn't like Mac style.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
Well, it does seem to work with either unix or mac linebreaks.
I wasn't outputting the result to a file so I wasn't getting the substitution to stick. Another unix lesson learned.
Thanks for the help.
kman
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |