Sed abandon the X character

I'm looking for a sed command to strip characters from the 11th (and thus keep the first 10) on lines starting with ">". So I want to basically change this file

>LEP004_Iphiclides_podalirius
GCCTCGGCTCACTTGGAAGGTGG

>LEP054_Danaus_plexippus
GGTCGTTGACCTCACTGTTTGCA

      

Next:

>LEP004_Ip
GCCTCGGCTCACTTGGAAGGTGG

>LEP054_Da
GGTCGTTGACCTCACTGTTTGCA

      

I tried this command: sed -n '= / {s / ^ (. {10}). * / \ 1 / g; p}' seq.fas> seq_modif.fas, but it just prints the sequence headers (not the sequences DNA)

Thank!

+3


source to share


3 answers


You can use this command sed

:



sed '/^>/s/^\(.\{10\}\).*/\1/' file
>LEP004_Ip
GCCTCGGCTCACTTGGAAGGTGG

>LEP054_Da
GGTCGTTGACCTCACTGTTTGCA

      

+2


source


This might work for you (GNU sed):



sed '/^>/s/.//11g' file

      

+2


source


Here's the awk

version:

$ awk '/^>/ {$0=substr($0,1,10)} 1' seq.fas

      

+2


source







All Articles