I have a file containing the following informations:    gene            3025..3855                     /gene=Sp34_10000100                     /ID=Sp34_10000100     CDS             join(3025..3106,3722..3855)                     /gene=Sp34_10000100                     /codon_start=1                     /ID=Sp34_10000100.t1.cds1,Sp34_10000100.t1.cds2     mRNA            3025..3855                     /ID=Sp34_10000100.t1                     /gene=Sp34_10000100     gene            12640..13470                     /gene=Sp34_10000200                     /ID=Sp34_10000200     CDS             join(12640..12721,13337..13470)                     /gene=Sp34_10000200                     /codon_start=1                     /ID=Sp34_10000200.t1.cds1,Sp34_10000200.t1.cds2     mRNA            12640..13470                     /ID=Sp34_10000200.t1                     /gene=Sp34_10000200     gene            15959..20678                     /gene=Sp34_10000300                     /ID=Sp34_10000300     CDS             join(15959..16080,16268..16367,18913..19116,20469..20524,20582..20678)                     /gene=Sp34_10000300                     /codon_start=1                     /ID=Sp34_10000300.t1.cds1,Sp34_10000300.t1.cds2,Sp34_10000300.t1.cds3,Sp34_10000300.t1.cds4,Sp34_10000300.t1.cds5     mRNA            15959..20678                     /ID=Sp34_10000300.t1                     /gene=Sp34_10000300     gene            22255..23085                     /gene=Sp34_10000400                     /ID=Sp34_10000400I want to delete all the gene sections but CDS and mRNA information should be there. The output should be like this:CDS             join(3025..3106,3722..3855)                     /gene=Sp34_10000100                     /codon_start=1                     /ID=Sp34_10000100.t1.cds1,Sp34_10000100.t1.cds2     mRNA            3025..3855                     /ID=Sp34_10000100.t1                     /gene=Sp34_10000100     CDS             join(12640..12721,13337..13470)                     /gene=Sp34_10000200                     /codon_start=1                     /ID=Sp34_10000200.t1.cds1,Sp34_10000200.t1.cds2     mRNA            12640..13470                     /ID=Sp34_10000200.t1                     /gene=Sp34_10000200     CDS             join(15959..16080,16268..16367,18913..19116,20469..20524,20582..20678)                     /gene=Sp34_10000300                     /codon_start=1                     /ID=Sp34_10000300.t1.cds1,Sp34_10000300.t1.cds2,Sp34_10000300.t1.cds3,Sp34_10000300.t1.cds4,Sp34_10000300.t1.cds5     mRNA            15959..20678                     /ID=Sp34_10000300.t1                     /gene=Sp34_10000300Please give me any suggestion how to do this.
Finding specific words and delete all the lines after it
awk;sed
awk is usually easier to read and understand:Here is a simple program that writes by default, and toggle a wewrite to 0 (= off, we will not write) when it sees a line where the first word is gene, and put it back on when he sees a line where the first word is CDS or mRNA :awk '  BEGIN                               { weprint=1 }  ( $1 == gene )                    { weprint=0 }  ( $1 == CDS ) || ( $1 == mRNA ) { weprint=1 }  ( weprint == 1)                     { print $0 ;}  '  file_to_readBEGIN is done before any lines are read.The other ( test ) { action if test successful } are parsed for each line of input (... unless an action contains next, which then would ignore the rest of those and instead would go fetch the next line of input)This will only print sections CDS and mRNA and not geneThis could be golfed (for example, the default action for a successfull 'test' is to print $0, so you could have just ( weprint == 1) as the last line, but it would be less clear to grasp, imo...)