Comparing two files with overlapping regions and get their associated information I have two file that have overlapping regions. One file has chromosomes, position, CNV data and samples.Other file has chromosomes, positions and ensemble ids of genes.

Here is some lines of two files.

contig  start   end     type  bi-allelic  S1  S2  S3
chr1    12048   177033    DUP FALSE   -1  22  24
chr1    12048   89237     DUP FALSE   12  10  -1
chr1    2985712 3355300   DEL   TRUE  2   2   2


Second file is like this

chr1    901877  911245  gene_id "ENSG00000187583.6"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
chr1    22013   41670 gene_id "ENSG00000160075.10"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
chr1    2985732 3355185 gene_id "ENSG00000142611.12"


I want output like this.

chr1    22013   41670 gene_id "ENSG00000160075.10"  DUP FALSE   12  10  -1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
chr1    2985732 3355185 gene_id "ENSG00000142611.12" DEL   TRUE  2   2   2 


Is there any way to do this?
You can use bedtools intersect and cut the results:

$ cat file1.bed
chr1    12048   177033  DUP FALSE   -1  22  24
chr1    12048   89237   DUP FALSE   12  10  -1
chr1    2985712 3355300 DEL TRUE    2   2   2

$ cat file2.gtf
chr1    22013   41670   gene_id "ENSG00000160075.10"
chr1    22013   41670   gene_id "ENSG00000160075.10"
chr1    2985732 3355185 gene_id "ENSG00000142611.12"

$ bedtools intersect -a file2.gtf -b file1.bed -wb | cut -f 1-4,8-11
chr1    22013   41670   gene_id "ENSG00000160075.10"    DUP FALSE   12  10
chr1    22013   41670   gene_id "ENSG00000160075.10"    DUP FALSE   -1  22
chr1    2985732 3355185 gene_id "ENSG00000142611.12"    DEL TRUE    2   2