7

I am trying something new that I have done on UNIX successfully but have no idea how to do on windows.

So I save a text file, let's say test1.txt and 12 hours later compare the test2.txt (which is test1.txt with changes added during the 12 hours, almost guaranteed to be at the end of the file) to test1.txt and then output just the text differences to a third file, diff.txt

1 action
2 action
3 action
4 action 
5 action

and test2.txt looks like

1 action
2 action
3 action
4 action 
5 action
6 action
7 action
8 action

then the output to the third file diff.txt would look like:

6 action
7 action
8 action

with just the text that has been added, no info regarding lines or comparisons,just a basic output of the differences.

I am COMPLETELY new to this, have looked around and it seems I can write a batch file (.bat) that will basically just act as a UNIX script would.

Sorry for my basic question but I've googled the question and can't seem to figure it out.

Erwin
  • 4,757
  • 3
  • 31
  • 41
Martin O Leary
  • 633
  • 2
  • 10
  • 29

3 Answers3

9

The Simplest and fastest method is using findstr command it will compare and return the result to new file here the script

findstr /vixg:Z:\misc\test1.txt Z:\misc\misc\test2.txt > Z:\misc\misc\test3.txt


findstr /vixg:<source file> <target file> > outputfile

here

/v   : Prints only lines that do not contain a match.
/i   : Specifies that the search is not to be case-sensitive.
/x   : Prints lines that match exactly.
/g: file   : Gets search strings from the specified file.
jacob justin
  • 156
  • 1
  • 5
1

You can try something like this:-

  @echo off
   :main
   fc c:\filename r:\filemame > nul
   if errorlevel 1 goto error

   :next
   echo insert next CD
    pause
  goto main

  :error
  echo failed check

From the source

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
0

You might want to check this out:

http://gnuwin32.sourceforge.net/packages.html

There are ports of *nix utilities, including one for diff so you won't have to reinvent the wheel.

cowboydan
  • 1,062
  • 7
  • 15