This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Proper sed format to remove and of line characters?

Hi everyone,

I have a fasta file with some junk at the end of many lines, which I would like to remove using sed.

I have tried these formats, but am getting errors inre illegal variable names:

sed -e "s/NNG$//g"

sed -e "s/NNG\$//g"

sed -e "s/NNG$//g"

sed -e "s/NNG+$//g"

sed -e "s/NNG*$//g"

I'm stumped. Any advice will be appreciated.

sed fasta

Hello,

try to use ' instead of ".

fin swimmer

Thanks finswimmer.

Sadly, that didn't seem to solve the problem.

Hello stacy734 ,

please use the ADD REPLY button below the post you like to reply to.

Could you please:

  • post an example of the input file
  • post the exact error message you receive
  • tell us what OS you are using
  • tell which shell (bash?, zsh?, ...) you are using

?

Thanks!

fin swimmer

Show us an example of a fasta sequence with what you want to remove

1 answer

You're matching , or "all of []" Try "." instead, or "match all occurences of [anything]":

sed -e 's/NNG.*$//'

# Input
goodNNGS
goodNNGS
goodNNGC
goodNNGA

# Output
good
good
good
good

Log in to answer this question.