Compare two header

I have to write a script to compare headers of two file.

1st_file

col1,col2,col3,col4,col5

2nd_file

col6,col1,col7,col8,col9

i have to compare the 2nd file with 1st and if the columns match i.e. col1 from 1st file is present in 2nd file then the output should show the entire 2nd column of 2nd file.

Please show a representative sample of input, desired output, attempts at a solution and specify what OS and versions are being used.

This is asked very often - you can use the search function of the forum and type in "compare two files" and get a lot of hits with examples.