i have a text file as belows, it includes 2 columns, 1st is the column name, 2nd is the file_name
data_file.txt
column_name file_name
col1 file1
col2 file2
col3 file1
col4 file1
col5 file2
now, i would like to output below result to a text file, which returns all the column name by file name as belows.
file_name column_name
file1 col1,col3,col4
file2 col2,col5
how can i write a shell script to read the data_file.txt line by line and output the result as above by file name.