Use sed (or another command line) to replace the character set with another one

I need to invert a DNA text string by changing all numbers from A to T, from T to A, C-> G and G-> C.

Can I elegantly handle this in sed (or on another command line) without a chain of chains of global replacement commands?

+4
source share
2 answers

this is how you do it with sed

$ echo "test ATCG GATC test" | sed 'y/ATCG/TAGC/' test TAGC CTAG test 
+4
source

use tr.
cat file | tr ATCG TAGC

+6
source

All Articles