<p>Either the <code>zcat</code> command or <code>gunzip -c</code> will decompress the file in a streaming fashion to the standard output without writing the decompressed data to disk. Pipe the output to <code>cut</code>, <code>sed</code>, etc.</p>
<p>Try</p>
<pre><code>zcat 00-All.vcf.gz | cut -f 3 | sed 's/[\t]/,/g' &gt; cols.csv
</code></pre>
<p>or</p>
<pre><code>gunzip -c 00-All.vcf.gz | cut -f 3 | sed 's/[\t]/,/g' &gt; cols.csv
</code></pre>
<p>But if you just want a single 'column' (I presume you mean field), then you are better off just doing <code>bcftools query</code>.</p>

CC BY-SA 4.0
2022-01-26T15:38:32.233Z
On some systems I have issues with `zcat` but `gunzip -c` will also accomplish the same result.
Daniel Standage
CC BY-SA 4.0
2022-01-26T19:44:44.097Z
@Exhausted Don't use unix utilities for this - it needs a level of expertise that your post history suggests you do not have. Use bcftools instead, that will address a lot of edge cases that you can't foresee.
Ram RS
CC BY-SA 4.0
2022-01-26T20:47:03.307Z
tar can do select zip file search and extraction, but you're also data munging.
M__
CC BY-SA 4.0
2022-01-27T11:10:19.533Z
Thank you all, but why you down voting me?
Zizogolu
CC BY-SA 4.0
2022-01-27T11:29:30.397Z
I have No idea, I didn’t downvote.
user438383
CC BY-SA 4.0
2022-01-26T15:32:54.530Z
2022-01-26T16:05:22.977Z
2022-01-26T16:05:22.977Z
user438383
<p>I have a zipped vcf file of dbSNP hg38 version</p>
<p>No space left on my device to unzip that</p>
<p>I want to extract a column from that</p>
<p>I have tried this</p>
<pre><code>cut -f 3 00-All.vcf.gz | sed 's/[\t]/,/g' &gt; cols.csv
</code></pre>
<p>But that needs my vcf to be unzipped</p>
<p>Do you know any solution please?</p>

<vcf><snp><wes>
Extracting a column from a vcf file
# Extracting a column from a vcf file

(Asked by: username_0 on 2022-01-26)

I have a zipped vcf file of dbSNP hg38 version
No space left on my device to unzip that
I want to extract a column from that
I have tried this
cut -f 3 00-All.vcf.gz | sed 's/[\t]/,/g' > cols.csv

But that needs my vcf to be unzipped
Do you know any solution please?

**Tags:** vcf, snp, wes

---

## 1 answers

### Answer by username_1 on 2022-01-26. Score: 4 | Accepted answer

Either the zcat command or gunzip -c will decompress the file in a streaming fashion to the standard output without writing the decompressed data to disk. Pipe the output to cut, sed, etc.
Try
zcat 00-All.vcf.gz | cut -f 3 | sed 's/[\t]/,/g' > cols.csv

or
gunzip -c 00-All.vcf.gz | cut -f 3 | sed 's/[\t]/,/g' > cols.csv

But if you just want a single 'column' (I presume you mean field), then you are better off just doing bcftools query.

> **Comments:**
> **username_2**: On some systems I have issues with `zcat` but `gunzip -c` will also accomplish the same result.  
> **username_3**: @Exhausted Don't use unix utilities for this - it needs a level of expertise that your post history suggests you do not have. Use bcftools instead, that will address a lot of edge cases that you can't foresee.  
> **username_4**: tar can do select zip file search and extraction, but you're also data munging.  
> **username_0**: Thank you all, but why you down voting me?  
> **username_1**: I have No idea, I didn’t downvote.  

---

