H I O X INDIA
LINUX Commands
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Templates 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)
Español Français 中文 Deutsch
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

LINUX / UNIX cmd
Introduction
Commands in A
Commands in B
Commands in C
Commands in D
Commands in E
Commands in F
Commands in G
Commands in H
Commands in I
Commands in J
Commands in K
Commands in L
Commands in M
Commands in N
Commands in P
Commands in R
Commands in S
Commands in T
Commands in U
Commands in W
Commands in Y
More about Linux
Feedback




diff Linux Commands


Topic

What is Linux diff Command?




Explanation

diff COMMAND:
     diff command is used to find differences between two files.

SYNTAX:
  The Syntax is
     diff [options..] from-file to-file

OPTIONS:
     
-a Treat all files as text and compare them line-by-line.
-b Ignore changes in amount of white space.
-c Use the context output format.
-e Make output that is a valid ed script.
-H Use heuristics to speed handling of large files that have numerous scattered small changes.
-i Ignore changes in case; consider upper- and lower-case letters equivalent.
-n Prints in RCS-format, like -f except that each command specifies the number of lines affected.
-q Output RCS-format diffs; like -f except that each command specifies the number of lines affected.
-r When comparing directories, recursively compare any subdirectories found.
-s Report when two files are the same.
-w Ignore white space when comparing lines.
-y Use the side by side output format.



EXAMPLE:
     

Lets create two files file1.txt and file2.txt and let it have the following data.

Data in file1.txt Data in file2.txt
HIOX TEST
hscripts.com
with friend ship
hiox india
HIOX TEST
HSCRIPTS.com
with   friend    ship
  1. Compare files ignoring white space:
    diff -w file1.txt file2.txt
    This command will compare the file file1.txt with file2.txt ignoring white/blank space and it will produce the following output.
    
    2c2
    < hscripts.com
    ---
    > HSCRIPTS.com
    4d3
    < Hioxindia.com
    
  2. Compare the files side by side, ignoring white space:
    diff -by file1.txt file2.txt
    This command will compare the files ignoring white/blank space, It is easier to differentiate the files.
    
    HIOX TEST              HIOX TEST
    hscripts.com         | HSCRIPTS.com
    with friend ship       with   friend  ship
    Hioxindia.com        < 
    
    The third line(with friend ship) in file2.txt has more blank spaces, but still the -b ignores the blank space and does not show changes in the particular line, -y printout the result side by side.

  3. Compare the files ignoring case.
    diff -iy file1.txt file2.txt
    This command will compare the files ignoring case(upper-case and lower-case) and displays the following output.
    
    HIOX TEST              HIOX TEST
    hscripts.com           HSCRIPTS.com
    with friend ship     | with   friend  ship
    Hioxindia.com        <
    





        Find LINUX Commands... Hope you enjoy this tutorial. We welcome your Valuable feedbacks or suggestions on this LINUX / UNIX cmd reference. This is a copyright content.


privacy policy     license     sitemap
© 2004-2009 HIOX INDIA - hioxindia.com

Other Links