I have one script as below:
#!/bin/ksh
Outputfile1="/home/OutputFile1.xls"
Outputfile2="/home/OutputFile2.xls"
InputFile1="/home/InputFile1.sql"
InputFile2="/home/InputFile2.sql"
echo "Select hobby, class, subject, sports, rollNumber from Student_Table" >> InputFile1
echo "Select rollNumber ,First_name, Last_name from Name_Table" >>InputFile2
isql -Uusername -Ppassword -Ddatabase -Sserver_name -iInputFile1 -oOutputfile1
isql -Uusername -Ppassword -Ddatabase -Sserver_name -iInputFile2 -oOutputfile2
So after running the script i have two output files OutputFile1 and OutputFile2,one feild is common between both the files which is rollNumber
OutputFile1.xls:
hobby class subject sports rollNumber
dance 11 science cricket 1
dance 12 science cricket 3
dance 10 science cricket 1
dance 11 science cricket 2
dance 11 science cricket 1
dance 11 science cricket 2
OutputFile2.xls:
rollNumber First_name last_name
1 sonali kumari
2 anni Das
3 Rini kumari
Now i want a third file which merges both the OutputFile1 and OutputFile2 with the unique rollNumbers and gets the below output:
hobby class subject sports rollNumber First_name last_name
dance 11 science cricket 1 sonali kumari
dance 12 science cricket 3 Rini kumari
dance 10 science cricket 1 sonali kumari
dance 11 science cricket 2 anni Das
dance 11 science cricket 1 sonali kumari
dance 11 science cricket 2 anni Das
So it matches the second file with the first file and finds the unique number and merges the first_name and last_name with the appeopriate roll number.