Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.
Compare two text files, output diff to 3rd
Name: bobsingh1 Date: June 25, 2009 at 15:31:25 Pacific OS: Windows XP Subcategory: Batch
Comment:
I have tried fc and it just doesn't cut it. Two test files, filea has xxxxxx on first line and yyyyyy on second and zzzzzz on third and so on.. second file has xxxxxx and yyyyyy but no zzzzzz. I want to ouput the zzzzzz to the third file. No programming exp. plz help.
Name: Polygoned Date: June 25, 2009 at 16:03:58 Pacific
Reply:
How is it that fc doesn't cut it? Is it because of all the extra stuff that comes with the output?
0
Response Number 2
Name: bobsingh1 Date: June 25, 2009 at 16:20:11 Pacific
Reply:
Exactly. If there is a way, which I could not find, to get rid of all the before and after stuff, I am game but all the switches that I tried, I could not get it done.
0
Response Number 3
Name: ghostdog Date: June 25, 2009 at 16:36:12 Pacific
Reply:
If you can use GNU tools (see my sig coreutils), use the comm command.
Name: Polygoned Date: June 25, 2009 at 16:38:56 Pacific
Reply:
Since you say you have no programming skills I made a fairly user friendly program of it.
@echo off set /P file1=File one: set /P file2=File two: set /P output=Output file: fc %file1% %file2% /L > tmp.txt find /v /off "*****" tmp.txt > tmp2.txt find /v /off "%file1%" tmp2.txt > tmp3.txt find /v /off "%file2%" tmp3.txt > tmp4.txt for /F "skip=6" %%t in (tmp4.txt) do echo %%t >> %output% del tmp*.txt echo. echo Operation complete. Press any key to exit. pause > nul
I know, it's not beautiful and it has some limitations but it works. Don't forget to add .txt or whatever after the file names (just in case you didn't know).
0
Response Number 5
Name: Polygoned Date: June 25, 2009 at 16:51:25 Pacific
Reply:
Whoa. I just used my code on a large text with one word edited. Did not work well.. You should probably not use it. I don't know what to do now other than follow ghostdogs advice.
0
Response Number 6
Name: bobsingh1 Date: June 25, 2009 at 16:59:29 Pacific
Reply:
Well.. get back to work polygoned.. just kidding!!. Thanks a bunch for trying. To Ghostdog: I will have to convince my boss to use the tools. I doubt he will agree...
0
Response Number 7
Name: ghostdog Date: June 25, 2009 at 17:41:49 Pacific
Reply:
>> I doubt he will agree... tell him its to increase productivity and reducing your workload, so that you can concentrate on more important stuffs that takes time. i doubt he will disagree, unless he is living in prehistoric times.
Summary: Hi I have a problem with a script I'm trying to write. I want to compare two text files which have a list of directories and then extract the added (new) or missing (deleted) ones. The issue I hav...
Summary: I’m just getting started with VB Script and I need to figure out how to compare two text files for duplicate numbers and then echo those duplicates. For example each text files contains numbers like...
Summary: Hi, I'm having trouble merging two text files. I need to merge them so that the lines alternate, eg. doc1line1 doc2line1 doc1line2 doc2line2 etc. Is there any way to do this? Thanks. ...