<p>Reverse complement FASTA/Q:</p>
<pre><code>seqtk seq -r in.fa &gt; out.fa
</code></pre>
<p><a href="https://github.com/lh3/seqtk" rel="noreferrer">https://github.com/lh3/seqtk</a></p>

CC BY-SA 4.0
2020-10-01T14:30:59.010Z
2020-10-01T14:30:59.010Z
user9619
<p>You may either install the emboss package (<a href="http://emboss.sourceforge.net/download/" rel="nofollow noreferrer">http://emboss.sourceforge.net/download/</a>) and use the revseq program.
It contains many useful command-line programs such as the pairwise alignment tool needle.</p>

CC BY-SA 4.0
2020-04-29T09:02:25.250Z
2020-04-29T09:02:25.250Z
thomas duge de bernonville
<p>Thanks to <a href="http://manutamminen.info/posts/unix_tricks/" rel="noreferrer">Manu Tamminen</a> for this solution:</p>

<pre><code>echo ACCTTGAAA | tr ACGTacgt TGCAtgca | rev
</code></pre>

CC BY-SA 4.0
2020-01-06T09:44:26.933Z
And if I want to put it into a variable instead of echo it?
Adi Ro
CC BY-SA 4.0
2020-01-06T11:35:19.027Z
I would enclose the code in $() and assign to a variable assuming you are using a recent version of bash.
winni2k
CC BY-SA 4.0
2020-01-09T09:29:17.983Z
that works thanks!
Adi Ro
CC BY-SA 4.0
2019-04-15T09:46:12.963Z
2019-04-15T14:03:06.827Z
2019-04-15T14:03:06.827Z
winni2k
<p>I have a DNA sequence for which I would like to quickly find the reverse complement. Is there a quick way of doing this on the bash command line using only GNU tools?</p>

<sequence-analysis><phylogenetics><bash>
What is a quick way to find the reverse complement in bash
# What is a quick way to find the reverse complement in bash

(Asked by: username_0 on 2019-04-15)

I have a DNA sequence for which I would like to quickly find the reverse complement. Is there a quick way of doing this on the bash command line using only GNU tools?

**Tags:** sequence-analysis, phylogenetics, bash

---

## 3 answers

### Answer by username_0 on 2019-04-15. Score: 32 | Accepted answer

Thanks to Manu Tamminen for this solution:
echo ACCTTGAAA | tr ACGTacgt TGCAtgca | rev

> **Comments:**
> **username_3**: And if I want to put it into a variable instead of echo it?  
> **username_0**: I would enclose the code in $() and assign to a variable assuming you are using a recent version of bash.  
> **username_3**: that works thanks!  

---

### Answer by username_1 on 2020-10-01. Score: 7

Reverse complement FASTA/Q:
seqtk seq -r in.fa > out.fa

https://github.com/lh3/seqtk


---

### Answer by username_2 on 2020-04-29. Score: 2

You may either install the emboss package (<http://emboss.sourceforge.net/download/>) and use the revseq program.
It contains many useful command-line programs such as the pairwise alignment tool needle.


---

