Hey all,

I have a problem with using the grep command...

Im trying to parse lines in a file and read only characters t,c,a,g lower or upper case...but i keep getting trouble in the outcome:
for example axxxxtc should return atc but it doesnt...
heres my code:
result=`echo $line | grep [tcagTCAG]
any help plz?

Recommended Answers

All 4 Replies

grep will only match the lines (and return the entire line, not just the matched portions of it), and will not alter them. If you wish to alter the lines you are going to need to use sed, or something similar.

Can you please give me an example on how to use the "sed" command in this case??...

The Usage says:

sed [OPTION]... {script-only-if-no-other-script} [input-file]...

I'm not sure what "script" means in this case...i'm sorry i'm new to shell scripting... :(

blackrobe> Can you please give me an example on how to use the "sed" command in this case??...

I can do better than that, I will give you a link to an easy to understand tutorial that will initiate you to sed.

It works now..thank you so much for your help! =)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.