@Aia Thanks for looking into it. As i said there is no logic , i have randomly selected different columns of different files. I know the code i wrote was not correct that is the reason i mentioned pseudo code just to make it understand. Perhaps it created more confusion.
@Scrutinizer Thanks , this is what i was looking for. So the magic lies in p1=1 p2=2 file1 p1=2 p2=3 file2 p1=3 p2=2 file3 .
I don't know why thanks button is disable!
You need to pass number of fields which you want to print to function named eg--> print_val("1,3") and it should do the trick, since you want to read only very first line of each Input_file so I have used nextfile so that it will NOT go further for Input_file reading and will switch to next Input_file, moreover you need NOT to create many variables in case number of Input_file(s) are too much(tested this in GNU awk ).
If there's no logics to it, you can't program it. Programming means cast logics into code and apply repeatedly onto structurally identical but contentswise differing data, like everyday's log files, or multiple customer entries in a DB.
All above proposals convert your input data exactly as given into output exactly as in post#1. Why don't you do it in a one off editor session?