I have 24 files and I want to filter the files so each of them only contain rows with common strings in the first column of each file (in the example geneA and geneF are the only strings in Column1 common to each file). The output should preserve the 3 columns. The files are tab-delimited.
My files look like:
file1.txt
Column1 Column2 Column3
geneA 11 C
geneB 34 T
geneC 22 A
geneD 23 A
geneE 2 G
geneF 34 A
file2.txt
Column1 Column2 Column3
geneA 34 A
geneF 67 G
geneG 77 A
geneZ 45 G
geneY 99 T
file24.txt
Column1 Column2 Column3
geneA 22 A
geneF 7 T
geneL 34 C
geneK 66 A
geneM 34 T
geneP 47 G
My desired output would be:
file1.txt
Column1 Column2 Column3
geneA 11 C
geneF 34 A
file2.txt
Column1 Column2 Column3
geneA 34 A
geneF 67 G
file24.txt
Column1 Column2 Column3
geneA 22 A
geneF 7 T
awk
in the question tags, is there anything you have already tried (and maybe stumbled upon some unwanted behaviour) that could serve as a starting point for a possible solution?geneK
appear twice in file1 for example?