Is there a simple way to remove header lines from a vcf file.
Although I would like to retain the "original" VCF file as well. So ideally if results.vcf is my file then I want to create results-noheader.vcf as another file without the header lines.
#!/usr/bin/perl
use strict;
use warnings;
# no_headers.pl
# Reads a vcf file and removes unwanted headers
my $file = shift;
open my $F, $file;
LINE: while ($_=<$F>) {
next if /^##/; # This removes your headers
my @line = split /\t/;
print join(qq/\t/,@line);
}
Then you can do:
$ perl no_headers.pl your.vcf > no_headers.vcf
Of course, the one liner already submitted is quicker & better.
Oh sure...everyone wants one-liners... ;)
easy to apply and easy to forget ...