<p>That's what awk excels at! Simply set the input (<code>-F '\t'</code>) and output (<code>-v OFS='\t'</code>) record field separators to tab, and add 30 to the value of the fifth field on lines that don't start with a <code>#</code>:</p>
<pre><code>$ awk -F'\t' -v OFS='\t' '/^[^#]/{$5+=30}1' file.gtf 
##gff-version 3
sp_P45452_MMP13_HUMAN   SignalP-5.0 signal_peptide  1   19  30.9943 .   .   .
sp_Q8R2H5_PHLD_RAT  SignalP-5.0 signal_peptide  1   23  30.9861 .   .   .
</code></pre>

CC BY-SA 4.0
2021-09-16T13:50:16.907Z
yep this is the good stuff
Pallie
CC BY-SA 4.0
2021-09-16T13:51:32.953Z
Thank you so much! I am new to awk and this was super helpful!
obsmith
CC BY-SA 4.0
2021-09-16T13:42:33.933Z
2021-09-16T13:42:33.933Z
terdon
<p>I am trying to edit the &quot;end&quot; of my sequences in a GFF3 that contains 10000 sequences (so I do not want to do it manually). I want to add 30 residues to every single fragment. How can I do this?</p>
<p>Currently, I have a file that looks like this:</p>
<pre><code>##gff-version 3
sp_P45452_MMP13_HUMAN   SignalP-5.0 signal_peptide  1   19  0.994300    .   .   .
sp_Q8R2H5_PHLD_RAT      SignalP-5.0 signal_peptide  1   23  0.986089    .   .   .
</code></pre>
<p>I would like to edit it so that it looks like this:</p>
<pre><code>##gff-version 3
sp_P45452_MMP13_HUMAN   SignalP-5.0 signal_peptide  1   49  0.994300    .   .   .
sp_Q8R2H5_PHLD_RAT      SignalP-5.0 signal_peptide  1   53  0.986089    .   .   .
</code></pre>
<p>Thank you!</p>

<bedtools><gff3>
Edit end column in GFF3 file
# Edit end column in GFF3 file

(Asked by: username_0 on 2021-09-16)

I am trying to edit the "end" of my sequences in a GFF3 that contains 10000 sequences (so I do not want to do it manually). I want to add 30 residues to every single fragment. How can I do this?
Currently, I have a file that looks like this:
##gff-version 3
sp_P45452_MMP13_HUMAN   SignalP-5.0 signal_peptide  1   19  0.994300    .   .   .
sp_Q8R2H5_PHLD_RAT      SignalP-5.0 signal_peptide  1   23  0.986089    .   .   .

I would like to edit it so that it looks like this:
##gff-version 3
sp_P45452_MMP13_HUMAN   SignalP-5.0 signal_peptide  1   49  0.994300    .   .   .
sp_Q8R2H5_PHLD_RAT      SignalP-5.0 signal_peptide  1   53  0.986089    .   .   .

Thank you!

**Tags:** bedtools, gff3

---

## 1 answers

### Answer by username_1 on 2021-09-16. Score: 3 | Accepted answer

That's what awk excels at! Simply set the input (-F '\t') and output (-v OFS='\t') record field separators to tab, and add 30 to the value of the fifth field on lines that don't start with a #:
$ awk -F'\t' -v OFS='\t' '/^[^#]/{$5+=30}1' file.gtf 
##gff-version 3
sp_P45452_MMP13_HUMAN   SignalP-5.0 signal_peptide  1   19  30.9943 .   .   .
sp_Q8R2H5_PHLD_RAT  SignalP-5.0 signal_peptide  1   23  30.9861 .   .   .

> **Comments:**
> **username_2**: yep this is the good stuff  
> **username_0**: Thank you so much! I am new to awk and this was super helpful!  

---

