Extract all the content after a specific data

My input:
>seq_1
DSASSTRRARRRRTPRTPSLRSRRSDVTCS
>seq_3
RMRLRRWRKSCSERSRRSN
>seq_8
RTTGLSERPRLPTTASRSISSRWTR
>seq_10
NELPLEKGSLDSISIE
>seq_9
PNQGDAREPQAHLPRRQGPRDRPLQAYA+
QVQHRRHDHSRTQH
LCRRRQREDCDRLHR
>seq_4
DRGKGQAGCRRPQEGEALVRRCS>seq_6
FA*GLAAQDGEA*SGRG

My output: Extract all the data after seq_3:
>seq_8
RTTGLSERPRLPTTASRSISSRWTR
>seq_10
NELPLEKGSLDSISIE
>seq_9
PNQGDAREPQAHLPRRQGPRDRPLQAYA+
QVQHRRHDHSRTQHLCRRRQREDCDRLHR
>seq_4
DRGKGQAGCRRPQEGEALVRRCS>seq_6
FA*GLAAQDGEA
SGRG

Does anybody got the idea to get my desired output?
It seems like awk and sed able to do it.
But I not very sure how to solve it out.
Thanks a lot for all of your advice :slight_smile:

you had previous posts similar to this. so i expect you to already have some code. show it.

code

sed -n '/seq_8/,$ {
p
} 'file.txt > out_file

Thanks a lot, it is worked perfectly :slight_smile:

Hi,
I just found out that the code that you suggested also will print out the content of seq_81,seq_800,etc
Do you have any idea just only specific and only print out the content that matched with seq_8?
Thanks a lot ^^

easily you can put ur string inside this "\<\>" and you will get the exact pattern you want.

sed -n '/\<seq_8\>/,$ {
p
} ' file.txt > out_file

above you will get seq_8 only if you want seq_80 do this:
sed -n '/\<seq_80\>/,$ {
p
} ' file.txt > out_file

and so on.

hi,
I just try both of the code that you suggested, it print out all the content of the file :frowning:
I not sure what is the wrong that I had did :frowning:
Do you know what is the reason?
Thanks again, ahmad

did you put -n option after the sed command.
BR

yup.
I just copy exactly what you post and change the file name only.
Unfortunately, it print out all other sequence as well :frowning:

what is the sytem (do uname -a and send the o/p).

and try the old command without \<\> what do u get?

I try both the old and new version, all get the same result which print out all the things :frowning:
my version is Linux ia64

kindly write the code and do not copy it.

sad :frowning:
don't know why I can't get my desired output result :frowning:

its working likem a charm with me ...I don't know what did u do!!!! thats strange man!!!!

check the spaces and re-write the sed command again don't leave spaces after { or }...

sed  -n  ' /\<pattern\>/, $ {
p
}
'    input_file > output_file

Best Regards

I also feel weird about it :frowning:
Really thanks for your help and patience and explanation all the time, ahmad ^^

Hi Patrick, do these commands fail too?

sed -n '/>seq_8$/,$p' infile
awk '/>seq_8$/,0' infile

Thanks a lot, ahmad and sorry for disturbing you :frowning:
You're right. All of your command or code work perfectly for my test sequence.
I just found out that I did a careless mistakes when run the code that you suggested :frowning:
Really thanks a lot for your help.
My problem is solved finally ^^

---------- Post updated at 08:23 PM ---------- Previous update was at 08:21 PM ----------

Hi Scrutinizer,
Thanks a lot for your suggestion code ^^
Both of your code and ahmad suggested's code work perfectly for my test sequence.
Sorry that my careless mistakes create trouble for you all :frowning:

---------- Post updated at 09:53 PM ---------- Previous update was at 08:23 PM ----------

Hi, I just found out that both of your suggested code, will print out all those sequence after seq_8 as well :frowning:
Do you got better idea, just let it extract only seq_8 ?
Really thanks for your help ^^

---------- Post updated at 09:58 PM ---------- Previous update was at 09:53 PM ----------

Hi Ahmad,
the same problem as Scrutinizer's code, happen to your suggested code as well :frowning:
It will extract all those sequence content after seq_8 as well :frowning:

Well that is what you asked for:

Or is that not what you mean? Can you give a better sample input and output:

Oic.
Sorry for let you misunderstanding my question.
I apologize and sorry for it :frowning:
My thread one's problem already solved by ahmad ^^
Regarding to thread number 5,
Actually I just asking about how to extract only those content that matched with seq_8.
At this time, input :
>seq_1
DSASSTRRARRRRTPRTPSLRSRRSDVTCS
>seq_3
RMRLRRWRKSCSERSRRSN
>seq_8
RTTGLSERPRLPTTASRSISSRWTR
>seq_10
NELPLEKGSLDSISIE
>seq_9
PNQGDAREPQAHLPRRQGPRDRPLQAYA+
QVQHRRHDHSRTQH
LCRRRQREDCDRLHR
>seq_4
DRGKGQAGCRRPQEGEALVRRCS>seq_6
FA*GLAAQDGEA*SGRG

My output: Extract only the data of seq_8:
>seq_8
RTTGLSERPRLPTTASRSISSRWTR

Sorry again, Scrutinizer.
I will notice my mistakes in future.
Hope for your understanding.
sorry :frowning:

awk '$1~/>/{f=0}/>seq_8$/{f=1}f' file

Too many examples, too many solutions.
You should start solving your own problems :cool: