Here is an example showing the use of diff on two file that differ only in a few lines.
[amit@dslamit doublyLinkedLists]$ diff Node.h library/Node.h 8d7 < #include "Job.h" 14c13 < JobPtr data; --- > void *obj; 19,20c18,19 < NodePtr createNode (JobPtr data); < void freeNode(NodePtr node); --- > NodePtr createNode (void *obj); > void freeNode(NodePtr node, void (*freeObject)(void *)); [amit@dslamit doublyLinkedLists]$
Here is another use of diff on the same two files, except this time we want to ignore all white space and have the output be side by side and no wider than 80 characters wide.
[amit@dslamit doublyLinkedLists]$ diff -w -b --side-by-side -W 80 Node.h library/Node.h
#ifndef __NODE_H #ifndef __NODE_H
#define __NODE_H #define __NODE_H
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "common.h" #include "common.h"
#include "Job.h" <
typedef struct node Node; typedef struct node Node;
typedef struct node * NodePtr; typedef struct node * NodePtr;
struct node { struct node {
JobPtr data; | void *obj;
NodePtr next; NodePtr next;
NodePtr prev; NodePtr prev;
}; };
NodePtr createNode (JobPtr data); | NodePtr createNode (void *obj);
void freeNode(NodePtr node); | void freeNode(NodePtr node, void (*fr
#endif /* __NODE_H */ #endif /* __NODE_H */
[amit@dslamit doublyLinkedLists]$
The
shows lines that are missing in the second file,
shows the lines
missing in the second file, while the | shows the lines that are
different.