📄 ch28_06.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 28] 28.6 Choosing Sides with sdiff </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:44:45Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch28_01.htm"TITLE="28. Comparing Files"><LINKREL="prev"HREF="ch28_05.htm"TITLE="28.5 Comparing Files Alongside One Another "><LINKREL="next"HREF="ch28_07.htm"TITLE="28.7 diff for Very Long Files: bdiff "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch28_05.htm"TITLE="28.5 Comparing Files Alongside One Another "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 28.5 Comparing Files Alongside One Another "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 28<BR>Comparing Files</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch28_07.htm"TITLE="28.7 diff for Very Long Files: bdiff "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 28.7 diff for Very Long Files: bdiff "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-7962">28.6 Choosing Sides with sdiff </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-31266"></A><ACLASS="indexterm"NAME="AUTOID-31268"></A>One problem you might be tempted to tackle with <SPANCLASS="link"><EMCLASS="emphasis">diff3</EM> (<ACLASS="linkend"HREF="ch28_02.htm"TITLE="Comparing Three Different Versions with diff3 ">28.2</A>)</SPAN>is sorting out the mess that can happen if two people make copies of thesame file, and then make changes to their copies. You often find that one version has some things right and anotherversion has other things right.What if you wanted to compile a single version of this document thatreflects the changes made to each copy?You want to select which version is correct for each set of differences.An effective way to do this would be to use<SPANCLASS="link"><EMCLASS="emphasis">sdiff</EM> (<ACLASS="linkend"HREF="ch28_04.htm"TITLE="Side-by-Side diffs: sdiff ">28.4</A>)</SPAN>.(Of course, the best thing to do is to prevent the problem in the firstplace, by using<SPANCLASS="link">SCCS or RCS (<ACLASS="linkend"HREF="ch20_12.htm"TITLE="Protecting Files with SCCS or RCS ">20.12</A>)</SPAN>.)</P><PCLASS="para">One of the most powerful uses of <EMCLASS="emphasis">sdiff</EM> is tobuild an output file by interactively choosing between different versions oftwo files.To do this, you have to specify the <EMCLASS="emphasis">-o</EM> option and the name of anoutput file to be created.The <EMCLASS="emphasis">sdiff</EM> command thendisplays a <CODECLASS="literal">%</CODE> prompt after each set of differences.</P><PCLASS="para">You can compare the different versions and selectthe one that will be sent to the output file.Some of the possible responses are <CODECLASS="literal">l</CODE> tochoose the left column, <CODECLASS="literal">r</CODE> to choose the right column,and <CODECLASS="literal">q</CODE> to exit the program.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">TOR</SPAN>, <SPANCLASS="authorinitials">JP</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch28_05.htm"TITLE="28.5 Comparing Files Alongside One Another "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 28.5 Comparing Files Alongside One Another "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch28_07.htm"TITLE="28.7 diff for Very Long Files: bdiff "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 28.7 diff for Very Long Files: bdiff "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">28.5 Comparing Files Alongside One Another </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">28.7 diff for Very Long Files: bdiff </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed & awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -