I have a very big compressed vcf file with over 8000 samples. I wanted to extract out  data for those samples whose name start with first three characters "TMS" so that I can have a new vcf file with those samples and their variants data only. Could anyone help me out with the vcftools or bcftools command to accomplish this?
Thanks


    gunzip -c in.vcf.gz | grep "#CHROM" -m 1  | cut -f 10- | tr "\t" "\n" | grep ^TMS > samples.txt
    
    bcftools view --samples-file  samples.txt  in.vcf.gz

