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?

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.

This question has already been answered. Start a new discussion instead.