Linux/Unix Commands





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
LINUX / UNIX cmd
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Introduction
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in A
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in B
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in C
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in D
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in E
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in F
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in G
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in H
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in I
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in J
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in K
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in L
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in M
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in N
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in P
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in R
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in S
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in T
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in U
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in W
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Commands in Y
Forums Ask your doubts
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example More about Linux
LINUX/UNIX Commands tutorial/reference - Find linux cmd, syntax, example Feedback
 





diff Linux Commands


Tutorials 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        <
    




A Note

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.


Other Links

web hosting

 

Free Hosting

Top Hosting Companies