How to compare 2 file to newfile......


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to compare 2 file to newfile......
# 1  
Old 08-21-2008
How to compare 2 file to newfile......

Hi all Member

i want compare 2 file to newfile
I am new to shell script, just wanted you guy to help.

example file A

CM-00000BN_Oth-VAS-0000392
CM-00000BNSEED_Oth-Spe-0000392
CM-00000KJ_Pos-Pro-0000806
CM-00000KJ_Pos-Pro-0000810
CM-00000KJ_Pos-Pro-0000812
CM-00000KJ_Pos-Pro-0000814
CM-00000KJ_Pos-Pro-0000816
CM-00000KJ_Pos-Pro-0000818
CM-00000KJ_Pos-Pro-0000822
CM-00000KJ_Pos-Pro-0000826
CM-00000KJ_Pos-Pro-0000830
CM-00000KJ_Pos-Pro-0000834
CM-00000KJ_Pos-Pro-0000838

example file B

CM-00000BN_Oth-VAS-0000392
CM-00000BNSEED_Oth-Spe-0000392
CM-00000KJ_Pos-Pro-0000806
CM-00000KJ_Pos-Pro-0000811
CM-00000KJ_Pos-Pro-0000812
CM-00000KJ_Pos-Pro-0000814
CM-00000KJ_Pos-Pro-0000816
CM-00000KJ_Pos-Pro-0000818
CM-00000KJ_Pos-Pro-0000822
CM-00000KJ_Pos-Pro-0000826
CM-00000KJ_Pos-Pro-0000831
CM-00000KJ_Pos-Pro-0000834
CM-00000KJ_Pos-Pro-0000838

i want to check line by line


if line of file A match file B
example result

CM-00000BN_Oth-VAS-0000392 CM-00000BN_Oth-VAS-0000392 is ok
CM-00000BNSEED_Oth-Spe-0000392 CM-00000BNSEED_Oth-Spe-0000392 is ok

if line of file A not match file B
example result

CM-00000KJ_Pos-Pro-0000810 CM-00000KJ_Pos-Pro-0000811 is faile
CM-00000KJ_Pos-Pro-0000830 CM-00000KJ_Pos-Pro-0000831 is faile



้help me please....

# 2  
Old 08-21-2008
Try using the comm command. You may need to manipulate the output a little to get it exactly the way you want it...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies

2. UNIX for Beginners Questions & Answers

Character screening and paste into newfile in columns instead of rows

QL10169_SAUJANA%SubNetwork=ONRM_ROOT_MO_R,SubNetwork=ERBS_KCRN11,MeContext=QL10169_SAUJANA_5 %External_Link_Failure %X2_link_problem_to_one_or_several_neighbouring_eNodeBs. QL10187_MATANG_JAYA_2%SubNetwork=ONRM_ROOT_MO_R,SubNetwork=ERBS_KUCHING,MeContext=QL10187_MATANG_JAYA_2_3... (2 Replies)
Discussion started by: Ankit Vyas
2 Replies

3. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

4. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

5. Shell Programming and Scripting

splitting newfile.txt file and executing each splitted files

split -l $split_count newfile.txt for i in $split_files* do if test -s $workingdir/$split_files* then ./<$i.out> fi done ... (4 Replies)
Discussion started by: sanjay mn
4 Replies

6. Shell Programming and Scripting

how to create one newfile and wants include some lines based on user request

I have one request, First it has to create one file and in that file it has to include some lines based on user request. Suppose user requested 10, then script needs to add 10 lines like below QAEVO_A1|A1 QAEVO_A2|A2 QAEVO_A3|A3 QAEVO_A4|A4 QAEVO_A5|A5 QAEVO_A6|A6 QAEVO_A7|A7... (8 Replies)
Discussion started by: sridhusha
8 Replies

7. Emergency UNIX and Linux Support

awk- add columns and make new column and save as newfile

Hi, I have file as below: 5 6 7 4 8 9 3 5 6 output needs to be another file with 4th column as $1+$2 and 5th column as $3+$4. sample output file 5 6 7 11 18 4 8 9 12 21 3 5 6 8 14 Anybody have answer Thanks in advance (3 Replies)
Discussion started by: vasanth.vadalur
3 Replies

8. Shell Programming and Scripting

sed *.csv from file > newfile with /n

I have a an output file with a format: something blah1.csv blah2.csv blah3.csv somethingelse and I'm trying to use sed to pull all the *.csv entries out and put them 1 per line on a new file. I can't quite figure out how to write them to a new file with carriage returns, is there a simple way... (8 Replies)
Discussion started by: unclecameron
8 Replies

9. Shell Programming and Scripting

Getting command output and putting into newfile

Hello All, I am using the below code: #!/bin/sh /omp/bin/TICLI "op:alarm,all" > filename for getting command output and then putting the output into newfile but the problem is this, that not the complete output goes into newfile and the script stops. for example: if this commands gives... (18 Replies)
Discussion started by: wakhan
18 Replies

10. Programming

compare XML/flat file with UNIX file system structure

Before i start doing something, I wanted to know whether the approach to compare XML file with UNIX file system structure. I have a pre-configured file(contains a list of paths to executables) and i need to check against the UNIX directory structure. what are the various approches should i use ? I... (6 Replies)
Discussion started by: shafi2all
6 Replies
Login or Register to Ask a Question