I have a .vcf.gz file, with the following aspect:
#CHROM POS ID REF ALT chr1 10894 chr1:10894:G:A G A chr1 10915 chr1:10915:G:A G A chr1 10930 chr1:10930:G:A G A
I want to modify the CHROM column to remove 'chr' and to replace it with nothing, so I want to get a result like the following:
#CHROM POS ID REF ALT 1 10894 chr1:10894:G:A G A 1 10915 chr1:10915:G:A G A 1 10930 chr1:10930:G:A G A
Therefore, I wrote the following command line:
zcat input.vcf.gz | sed 's/^chr//' > output.vcf.gz
and it worked. The problem is that I want to save the output file as a zipped one, with the vcf.gz extension. Even if I wrote 'output.vcf.gz', the output file is not zipped.
How can I modify a zipped file and then save it as a zipped file again?