sort GTF

(grep "^#" file.gtf; grep -v "^#" file.gtf | sort -k1,1 -k4,4n) > file_sorted.gtf
will first write all comments (lines beginning with #) tofile_sorted.gtf, then all other lines sorted first by the first column, alphanumerically, second by the fourth column, numerically. This works as well for files that do not contain comments. Sort compressed:
(zgrep "^#" file.gtf; zgrep -v "^#" file.gtf | sort -k1,1 -k4,4n) | gzip > file_sorted.gtf.gz
Share itShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *