GTF (General Transfer Format) is an identical version of  GFF2 and GFF3 replaced GFF2.  GTF file is used several aligners in sequence alignment and is also output by tools such as Cufflinks and TOPHAT/StringTie workflow.  There might be times, you might want to extract genes with more than one exon or want to know genes with one exon (monoexonic genes).

Let us say you obtained gtf from UCSC for hg38 and first few lines looks like following:


From this gtf file, you would like to extract genes with more than one exon: (please note that it could be any number - for eg more than 2 exons, 3 exons so and so forth)
=======================================================================
$ convert2bed --input=gtf --output=bed < ucsc.refgene.hg38.gtf | datamash -sg 4 count 8 | awk '$2>1' | wc -l
======================================================================= 
 (Please paste as one line. If you would like to extract genes with more than 3
exons, change awk '$2>3'. For 5, change $2>3 to $2>5. To extract genes, remove
wc -l at the end. wc -l counts the genes)

From this gtf file, you would like to extract genes with one exon: ========================================================================= 
 $ convert2bed --input=gtf --output=bed < ucsc.refgene.hg38.gtf | datamash -sg 4 count 8 | awk '$2==1'
========================================================================
(Please paste as one line. To extract genes, remove wc -l at the end. wc -l
counts the genes)