Compares two files and displays the differences in a side-by-side format.
sdiff [ -l | -s ] [ -o OutFile ] [ -w Number ] File1 File2
The sdiff command reads the files specified by the File1 and File2 parameters, uses the diff command to compare them, and writes the results to standard output in a side-by-side format. The sdiff command displays each line of the two files with a series of spaces between them if the lines are identical. It displays a < (less than sign) in the field of spaces if the line only exists in the file specified by the File1 parameter, a > (greater than sign) if the line only exists in the file specified by the File2 parameter, and a | (vertical bar) for lines that are different.
When you specify the -o flag, the sdiff command merges the files specified by the File1 and File2 parameters and produces a third file.
Note: The sdiff command invokes the diff -b command to compare two input files. The -b flag causes the diff command to ignore trailing spaces and tab characters and to consider other strings of spaces as equal.
sdiff chap1.bak chap1The sdiff command displays a side-by-side listing that compares each line of the chap1.bak and chap1 files.
sdiff -s -w 80 chap1.bak chap1The sdiff command displays the differences at the work station. The -w 80 flag and variable sets the page width to 80 columns. The -s flag indicates lines that are identical in both files will not be displayed.
sdiff -s -w 80 -o chap1.combo chap1.bak chap1The sdiff command combines the chap1.bak and chap1 files into a new file called chap1.combo. For each group of differing lines, the sdiff command prompts you which group to keep or whether you want to edit them using the ed command.
The staff.jan file contains the following lines:
Members of the Accounting Department Andrea George Karen Sam ThomasThe staff.apr file contains the following lines:
Members of the Accounting Department Andrea Fred Mark Sam Wendy
sdiff -o staff.year staff.jan staff.aprThe sdiff command will begin to compare the contents of the staff.jan and staff.apr files and write the results to the staff.year file. The sdiff command displays the following:
Members of the Accounting Dept Members of the Accounting Dept Andrea Andrea George | Fred %The % (percent sign) is the command prompt.
The sdiff command displays a sequence of digits, indicating the byte count of lines being merged. In this case, the byte count is 23.
Sam Sam Thomas | Wendy
Members of the Accounting Department Andrea George Karen Fred Mark Sam Thomas Wendy
/usr/bin/sdiff | Contains the sdiff command. |
Files Overview, Input and Output Redirection Overview in AIX Version 4.3 System User's Guide: Operating System and Devices.