|
grep till the 1st occurrence of a pattern
Hi I have a file like this
@<TRIPOS>MOLECULE
drugbank
1 1 -3.354658 1.791581 -0.875416 P.3 1 UNNAMED1 1.512600
2 2 -1.966044 0.997785 -0.876839 O.3 1 UNNAMED1 -0.551200
3 3 3.304945 1.379568 -0.783382 O.3 1 UNNAMED1 -0.532500
@<TRIPOS>SUBSTRUCTURE
1 UNNAMED1 1
@<TRIPOS>MOLECULE
drugbank_1
@<TRIPOS>ATOM
1 1 -3.774815 1.404774 -0.326354 P.3 1 UNNAMED1 1.512600
2 2 -2.271365 1.098882 0.128466 O.3 1 UNNAMED1 -0.551200
3 3 3.716964 0.714537 -1.002311 O.3 1 UNNAMED1 -0.532500
4 4
.....................................
so on
I want to grep the lines between "@<TRIPOS>MOLECULE" and "@<TRIPOS>SUBSTRUCTURE"...........THere are many occurances of the 2 patterns that i want.........
I am using sed -n '/@<TRIPOS>MOLECULE/,/@<TRIPOS>SUBSTRUCTURE/p' file
and
awk '/@<TRIPOS>MOLECULE/,/@<TRIPOS>SUBSTRUCTURE/' file
But they are giving all the occurances.........I want only the first occurance between the patterns........I do not want to use "csplit" command and then do the job which is very indirect......please suggest
|