Skip to main content
retag according to subject
Link
Archemar
  • 32.3k
  • 18
  • 75
  • 107

I am very new to shell script. One production script got deleted wrongly. We need to prepare the script ASAP. So need your help on this. My requirement is as below.

I have to compare two files, file1 and file2. Each file has 56 columns seperatedseparated by ||. First column is the employee number in the file, I will check whether same employee number is present in the second file or not. If not we will write the whole row to the output file. If same employee number is present in the file2, I need to compare value of each column. If data doesn't match, we have to write it to the output file. If values of each column match then we need to omit that record.

Sample File 
File 1

2620|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality and Wipro Way||| 2623|256034|131021|Mission Quality and Wipro Way||| 

File 2

2620|256034|234567|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 2623|256034|131021|Mission Quality and Wipro Way||| 

Sample Output:

2620|256034|131021|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 

Thanks and Regards, Biswa

I am very new to shell script. One production script got deleted wrongly. We need to prepare the script ASAP. So need your help on this. My requirement is as below.

I have to compare two files, file1 and file2. Each file has 56 columns seperated by |. First column is the employee number in the file, I will check whether same employee number is present in the second file or not. If not we will write the whole row to the output file. If same employee number is present in the file2, I need to compare value of each column. If data doesn't match, we have to write it to the output file. If values of each column match then we need to omit that record.

Sample File File 1

2620|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality and Wipro Way||| 2623|256034|131021|Mission Quality and Wipro Way||| 

File 2

2620|256034|234567|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 2623|256034|131021|Mission Quality and Wipro Way||| 

Sample Output:

2620|256034|131021|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 

Thanks and Regards, Biswa

I have to compare two files, file1 and file2. Each file has 56 columns separated by |. First column is the employee number in the file, I will check whether same employee number is present in the second file or not. If not we will write the whole row to the output file. If same employee number is present in the file2, I need to compare value of each column. If data doesn't match, we have to write it to the output file. If values of each column match then we need to omit that record.

Sample File 
File 1

2620|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality and Wipro Way||| 2623|256034|131021|Mission Quality and Wipro Way||| 

File 2

2620|256034|234567|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 2623|256034|131021|Mission Quality and Wipro Way||| 

Sample Output:

2620|256034|131021|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 
added code formating
Source Link
steeldriver
  • 83.9k
  • 12
  • 124
  • 175

I am very new to shell script. One production script got deleted wrongly. We need to prepare the script ASAP. So need your help on this. My requirement is as below.

I have to compare two files, file1 and file2. Each file has 56 columns seperated by |. First column is the employee number in the file, I will check whether same employee number is present in the second file or not. If not we will write the whole row to the output file. If same employee number is present in the file2, I need to compare value of each column. If data doesn't match, we have to write it to the output file. If values of each column match then we need to omit that record.

Sample File File 1 2620|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality and Wipro Way||| 2623|256034|131021|Mission Quality and Wipro Way||| File

2620|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality and Wipro Way||| 2623|256034|131021|Mission Quality and Wipro Way||| 

File 2 2620|256034|234567|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 2623|256034|131021|Mission Quality and Wipro Way|||

2620|256034|234567|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 2623|256034|131021|Mission Quality and Wipro Way||| 

Sample Output: 2620|256034|131021|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality|||

2620|256034|131021|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 

Thanks and Regards, Biswa

I am very new to shell script. One production script got deleted wrongly. We need to prepare the script ASAP. So need your help on this. My requirement is as below.

I have to compare two files, file1 and file2. Each file has 56 columns seperated by |. First column is the employee number in the file, I will check whether same employee number is present in the second file or not. If not we will write the whole row to the output file. If same employee number is present in the file2, I need to compare value of each column. If data doesn't match, we have to write it to the output file. If values of each column match then we need to omit that record.

Sample File File 1 2620|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality and Wipro Way||| 2623|256034|131021|Mission Quality and Wipro Way||| File 2 2620|256034|234567|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 2623|256034|131021|Mission Quality and Wipro Way|||

Sample Output: 2620|256034|131021|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality|||

Thanks and Regards, Biswa

I am very new to shell script. One production script got deleted wrongly. We need to prepare the script ASAP. So need your help on this. My requirement is as below.

I have to compare two files, file1 and file2. Each file has 56 columns seperated by |. First column is the employee number in the file, I will check whether same employee number is present in the second file or not. If not we will write the whole row to the output file. If same employee number is present in the file2, I need to compare value of each column. If data doesn't match, we have to write it to the output file. If values of each column match then we need to omit that record.

Sample File File 1

2620|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality and Wipro Way||| 2623|256034|131021|Mission Quality and Wipro Way||| 

File 2

2620|256034|234567|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 2623|256034|131021|Mission Quality and Wipro Way||| 

Sample Output:

2620|256034|131021|Mission Quality and Wipro Way||| 2621|256034|131021|Mission Quality and Wipro Way||| 2622|256034|131021|Mission Quality||| 

Thanks and Regards, Biswa

Source Link
Loading