| | |
Comparing two files and output values that match
![]() |
•
•
Join Date: Aug 2007
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
I have two files, both have a list of 6 digit values. I want to compare them and output the values that match up. The lines in each file are not supposed to contain the same value (in other words, line 1 in each file may or may not contain the value 000001, and so on).
1. Show where the same values exist in each file and relative position
example: line3 file1 is the same as line 227 file2
2. Count the number of occurrences of same values in file1 + file2
example: 201622 occurs 1 time in both files
344702 occurs 2 times in both files
001010 occurs 2 times in both files
3. TOTAL the number of times the same value exists in each file
example: (based on #2 above) file1 + file2 have a total of 5 occurrences of the same value.
4. Query against a specific value to see if (position agnostic) it appears in both files.
example: does 001010 exist at all in file1, file2
You might wish to consider reading up on three useful utilities one or more of which may be of assistance to you.
- comm
- diff
- sort
There is a Perl script or two out there which would accomplish one or more of the example goals I wondered about above.
May the Magnificent Arc and its Gaseous Shield be with you all. Do not weld anything while standing in ankle deep water. Use eye protection at all times, and avoid flying slag like the plague. Try not to weld while drunk.
Warm Regards & HTH,
Bob The Welder
•
•
Join Date: Feb 2006
Posts: 17
Reputation:
Solved Threads: 0
•
•
•
•
What is your goal here? For example, do you want to:
4. Query against a specific value to see if (position agnostic) it appears in both files.
example: does 001010 exist at all in file1, file2
I am trying to achieve #4. I want to know which values from file 1 match file 2. I'll check out those commands again, but I didn't seem to see how they could be helpful.
Thanks!
![]() |
Similar Threads
- problem with output values (Assembly)
- Need help! ....please help me (C++)
- Output 2D array? (C++)
- Script needed to check OID values (Shell Scripting)
- Array or String Comparing Assignment (C++)
- beginners program; can't get min value (C++)
- How to write files to an Excel application (Visual Basic 4 / 5 / 6)
Other Threads in the Shell Scripting Forum
- Previous Thread: capturing line from script output and appending to a file
- Next Thread: Timestamp
| Thread Tools | Search this Thread |





