Compare two text files, output diff to 3rd

June 25, 2009 at 15:31:25
Specs: Windows XP
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.

See More: Compare two text files, output diff to 3rd

Report •


#1
June 25, 2009 at 16:03:58
How is it that fc doesn't cut it? Is it because of all the extra stuff that comes with the output?

Report •

#2
June 25, 2009 at 16:20:11
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.

Report •

#3
June 25, 2009 at 16:36:12
If you can use GNU tools (see my sig coreutils), use the comm command.
C:\test>comm -3 file1.txt file2.txt

GNU win32 packages | Gawk


Report •

Related Solutions

#4
June 25, 2009 at 16:38:56
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).


Report •

#5
June 25, 2009 at 16:51:25
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.

Report •

#6
June 25, 2009 at 16:59:29
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...

Report •

#7
June 25, 2009 at 17:41:49
>> 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.

GNU win32 packages | Gawk


Report •


Ask Question