- Forums
- Scripts
- How To Compare Files In Windows And Or In Mac/linux
this are my notes i wrote to memorize how to compare files in windows linux or mac using the command line [8945], Last Updated: Sat May 18, 2024
author
Wed Dec 09, 2015
0 Comments
43 Visits
i am taking a class on git and one of the steps is to compare files.
this are my notes i wrote to memorize how to compare files in windows linux or mac using the command line.
as you can see from this screen shot, the following are the commands to automatically let the computer compare files instead of doing it manually yourself. this is a very time consuming task if you doing it by yourself, but letting the computer do it for you is much faster and easier.
WINDOWS:
FC - fc stands for file compare
EXAMPLE, on this example i am going to compare file1.html with file2.html
fc C\Production\file1.html C\Dev\file2.html
MAC or linux - diff (difference)
EXAMPLE, on this example i am going to compare file1.html with file2.html
diff -u C\Production\file1.html C\Dev\file2.html
NOTE: the -u option means 'unified diff', this will make the output much easier to read.
this is how you read the output:
line without a - or a + means no changes.
lines with -, means the lines were removed on the new Dev version
lines with + means the lines were added, or did not existed on the previous version
how to compare to different commits in git command:
git diff first_commit_id second_commit_id
colors:
green = lines added
red = lines removed
black = no changes