⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch20_13.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 20] 20.13 SCCS Basics </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-10-23T15:45:03Z"><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="ch20_01.htm"TITLE="20. Backing Up Files"><LINKREL="prev"HREF="ch20_12.htm"TITLE="20.12 Protecting Files with SCCS or RCS "><LINKREL="next"HREF="ch20_14.htm"TITLE="20.14 RCS Basics "></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="ch20_12.htm"TITLE="20.12 Protecting Files with SCCS or RCS "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 20.12 Protecting Files with SCCS or RCS "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 20<BR>Backing Up Files</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch20_14.htm"TITLE="20.14 RCS Basics "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 20.14 RCS Basics "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-7943">20.13 SCCS Basics </A></H2><PCLASS="para">If you don't know SCCS, you probably thought it was hard to learn.Not true.Here is a simple introduction to SCCS.</P><OLCLASS="orderedlist"><LICLASS="listitem"><PCLASS="para">Create a subdirectory called<EMCLASS="emphasis">SCCS</EM>in the directory where you keep the code or other text filesyou want to protect.</P></LI><LICLASS="listitem"><PCLASS="para">Add the characters<CODECLASS="literal">%W%&nbsp;&nbsp;&nbsp;%G%</CODE>somewhere in the file you want to place under SCCS.Put this in a comment field. That is, use<CODECLASS="literal">/*&nbsp;%W%&nbsp;&nbsp;&nbsp;&nbsp;%G% */</CODE>in a C program and<CODECLASS="literal">#&nbsp;%W%&nbsp;&nbsp;&nbsp;&nbsp;%G%</CODE>in a shell script.</P></LI><LICLASS="listitem"><PCLASS="para">Place the file under source code control. This is done by typing:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>sccs create</B></CODE> <CODECLASS="replaceable"><I>filename</I></CODE></PRE></BLOCKQUOTE></P></LI></OL><PCLASS="para">That's it. You're done.There are three more commands you need to know:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>sccs get</B></CODE> <CODECLASS="replaceable"><I>filename</I></CODE>% <CODECLASS="userinput"><B>sccs edit</B></CODE> <CODECLASS="replaceable"><I>filename</I></CODE>% <CODECLASS="userinput"><B>sccs delta</B></CODE> <CODECLASS="replaceable"><I>filename</I></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">&#13;You may also want to add the following to your list of<SPANCLASS="link">aliases (<ACLASS="linkend"HREF="ch10_02.htm"TITLE="Aliases for Common Commands ">10.2</A>)</SPAN>:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen"><BCLASS="emphasis.bold">C shell</B>      <CODECLASS="replaceable"><I>ksh, bash</I></CODE>alias Create 'sccs create'           alias Create='sccs create'alias Get 'sccs get'                 alias Get='sccs get'alias Edit 'sccs edit'               alias Edit='sccs edit'alias Delta 'sccs delta'             alias Delta='sccs delta'</PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-22702"></A>The<EMCLASS="emphasis">get</EM>command will get a copy of the file from the Source Code ControlSystem. The file will be<SPANCLASS="link">marked read-only (<ACLASS="linkend"HREF="ch22_02.htm"TITLE="Tutorial on File and Directory Permissions ">22.2</A>)</SPAN>.<ACLASS="indexterm"NAME="AUTOID-22706"></A>If you want to edit the file, use the <EMCLASS="emphasis">edit</EM>command.Once you are done, return the file to the <EMCLASS="emphasis">SCCS</EM> directorywith the command<ACLASS="indexterm"NAME="AUTOID-22710"></A><EMCLASS="emphasis">delta</EM>.Each time you store the file, you'll get a new versionnumber, or &quot;delta.&quot;</P><PCLASS="para">There are only two more commands that you will need to know.If you checked out a file for editing, and later on decided you didn'twant to edit, use:<ACLASS="indexterm"NAME="AUTOID-22714"></A></P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>sccs unedit</B></CODE> <CODECLASS="replaceable"><I>filename</I></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">and if you want a list of all files currently checked out, use:<ACLASS="indexterm"NAME="AUTOID-22721"></A></P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>sccs check</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">That's all there is to it! If you are not using SCCS, you should.It is the best way to protect yourself. It does not require dozens oftapes.</P><PCLASS="para">It is much easier to just type:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>sccs get -r1.12</B></CODE> <CODECLASS="replaceable"><I>filename</I></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">One command, and version 1.12 is restored.If it's not the right one, restore the version before or after the oneyou just grabbed. If you are worried that you are keeping 12 versionsof the file on the disk, and that this will use up a lot of diskspace, don't. SCCS stores the differences in a clever manner thatallows it to recover any version of the file in a single pass throughthe file. </P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-22734"></A><ACLASS="indexterm"NAME="AUTOID-22738"></A>Suppose you delete a file by accident?Well, if the file is just checked out with a <EMCLASS="emphasis">get</EM>,it will be retrieved and marked read-only, so deleting the file will cause <EMCLASS="emphasis">rm</EM>to ask you for confirmation.If you do delete it, you can recover it with another<EMCLASS="emphasis">get</EM>command.Suppose you check out a file with <EMCLASS="emphasis">edit</EM>,because you planned to change it.Well, if this file gets deleted accidentally, you would lose the mostrecent changes. This is why you should check your files back into SCCSfrequently&nbsp;- several times a day, if you wish.Do it whenever you make significant changes to the file, and it wouldbe difficult to remember all of the changes. Making hundreds ofchanges to a file without checking it back into the system is justbegging for trouble.</P><PCLASS="para">Good luck, and may you never delete another important file by accident.[There are several other revision control systems&nbsp;- including<SPANCLASS="link">RCS (<ACLASS="linkend"HREF="ch20_14.htm"TITLE="RCS Basics ">20.14</A>)</SPAN>,which is widely used and available on the CD-ROM.You can probably get the most help on whatever revision control system yourcolleagues use.Also see O'Reilly &amp; Associates' <EMCLASS="emphasis">Applying RCS and SCCS</EM>. <EMCLASS="emphasis">-JP</EM>&nbsp;]<ACLASS="indexterm"NAME="AUTOID-22749"></A></P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">BB</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="ch20_12.htm"TITLE="20.12 Protecting Files with SCCS or RCS "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 20.12 Protecting Files with SCCS or RCS "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="ch20_14.htm"TITLE="20.14 RCS Basics "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 20.14 RCS Basics "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">20.12 Protecting Files with SCCS or RCS </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">20.14 RCS Basics </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 &amp; 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 + -