I have a gz file that has several columns with headers. The first column looks something like this:
some header0 some header1
10:100000625 a
10:100000645 b
10:100002464 c
10:100003242 d
10:100003785 e
10:100004360 f
And another txt file which contains some of the first file 1st column entries (no header), ex:
10:100002464
10:100004360
I want to create a new gz file containing only the entries found in the txt file and keeps the headers.
some header0 some header1
10:100002464 c
10:100004360 f
The command I tried outputs a gz file with no headers. How can I keep them?
zcat my_file.gz | grep -Fw -f my_other_file.txt | gzip > my_file_new.gz