I have two files such as:
File_1
c1,c2,c3,c4
File_2
c1,c3,c2,c4
DA,CA,DD,CD
Thus, I want to make a File 3 using the File 1 as model using BASH:
File_3
c1,c2,c3,c4
DA,DD,CA,CD
In this example, the File_1 is a model of the correct disposition of the columns and the File_2 has the columns and their respective informations but in a wrong disposition. Thus, the File_3 used the file_1 as a template and ordered the information in the file_2 in a correct disposition.
In the example I just gave 4 columns, but my real file has 402 columns. So, to do an
awk -F"," '{print $1","$3","$2","$4}' File_2
or something like this, will not work because I dont know the position of the itens of the File_1 in the File_2 (for example the c1 column in the File_2 could be in the sixth, the second, or the last columns positions).
I hope that you can help me using BASH (if possible) and I would like an small explanation of the script, because I'm newbie and I don't know a lot the commands.
Thanks in advance.