sdiff Command Purpose Compares two files and displays the differences in a side-by-side format. Syntax sdiff [ -l | -s ] [ -o OutFile ] [ -w Number ] File1 File2 Description 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, a < (less than sign) in the field of spaces if the line only exists in File1, a > (greater than sign) if the line only exists in File2, and a | (vertical bar) for lines that are different. When you specify the -o flag, the sdiff command produces a third file by merging the files, specified by the File1 and File2 parameters, according to your instructions. 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. Flags -l Displays only the left side when lines are identical. -o OutFile Creates a third file, specified by the OutFile parame- ter, by a controlled line-by-line merging of the two files speci- fied by the File1 and the File2 parameters. The following sub- commands govern the creation of this file: e Starts the ed command with an empty file. e b Starts the ed command with both sides. e l Starts the ed command with the left side. e r Starts the ed command with the right side. l Adds the left side to the output file (the OutFile parameter). r Adds the right side to the output file (the OutFile parameter). s Stops displaying identical lines. v Begins displaying identical lines. q Exits the program. Each time you exit from the ed command, the sdiff command writes the resulting edited file to the end of OutFile. If you fail to save the changes before exiting, the sdiff command writes the initial input to OutFile. -s Does not display identical lines. -w Number Sets the width of the output line to the Number parame- ter. The default value of Number is 130 characters. Examples 1. To print a comparison of two files, enter: sdiff chap1.bak chap1 This displays a side-by-side listing that compares each line of the chap1.bak and chap1 files. 2. To display only the lines that differ, enter: sdiff -s -w 80 chap1.bak chap1 This displays the differences at the work station. The -w 80 flag and parameter sets the page width to 80 columns. The -s flag tells the sdiff command not to display lines that are ident- ical in both files. 3. To selectively combine parts of two files, enter: sdiff -s -w 80 -o chap1.combo chap1.bak chap1 This 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. Implementation Specifics This command is part of Base Operating System (BOS) Runtime. Files /usr/bin/sdiff Indicates the sdiff command. Related Information Files Overview in AIX Version 3.2 System User's Guide: Base and Devices. Input and Output Redirection Overview in AIX Version 3.2 System User's Guide: Base and Devices. The diff command, ed command.