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

📄 ch16_22.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 16] 16.22 Comparing Two Directory Trees with dircmp </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-08-04T21:37:58Z"><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="ch16_01.htm"TITLE="16. Where Did I Put That?"><LINKREL="prev"HREF="ch16_21.htm"TITLE="16.21 Finding All Directories with the Same Name "><LINKREL="next"HREF="ch16_23.htm"TITLE="16.23 Comparing Filenames in Two Directory Trees "></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="ch16_21.htm"TITLE="16.21 Finding All Directories with the Same Name "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 16.21 Finding All Directories with the Same Name "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 16<BR>Where Did I Put That?</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch16_23.htm"TITLE="16.23 Comparing Filenames in Two Directory Trees "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 16.23 Comparing Filenames in Two Directory Trees "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-5830">16.22 Comparing Two Directory Trees with dircmp </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-17679"></A><ACLASS="indexterm"NAME="AUTOID-17682"></A><ACLASS="indexterm"NAME="AUTOID-17685"></A><ACLASS="indexterm"NAME="AUTOID-17687"></A><ACLASS="indexterm"NAME="AUTOID-17690"></A>You have an original directory.You copy the files in it to another directory, edit some of them, andadd a few others.Later, you want to know the differences between the two directories.If your system's<SPANCLASS="link"><EMCLASS="emphasis">diff</EM> (<ACLASS="linkend"HREF="ch28_01.htm#UPT-ART-2680"TITLE="Checking Differences with diff ">28.1</A>)</SPAN>has a <EMCLASS="emphasis">-r</EM> (recursive) option, you canuse that.System V has <EMCLASS="emphasis">dircmp</EM>.The output of <EMCLASS="emphasis">dircmp</EM> is formatted with<SPANCLASS="link"><EMCLASS="emphasis">pr</EM> (<ACLASS="linkend"HREF="ch43_07.htm"TITLE="Quick-and-Dirty Formatting Before Printing ">43.7</A>)</SPAN>;you get66-line-long pages with headings:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>dircmp a b</B></CODE>Sep 16 09:26 1991  a only and b only Page 1./foo.tmp                                   ./defs.h   ...Sep 16 09:26 1991  Comparison of a b Page 1directory   .same        ./Makefiledirectory   ./datasame        ./data/test1same        ./data/test2   ...different   ./pqp.helpsame        ./pqs.help   ...</PRE></BLOCKQUOTE></P><PCLASS="para">In the <CODECLASS="literal">a&nbsp;only&nbsp;and&nbsp;b&nbsp;only</CODE> listing, files only in the first directoryare in the first column and files only in the second directory are in thesecond column.The <CODECLASS="literal">Comparison&nbsp;of&nbsp;a&nbsp;b</CODE> listing compares files that are in bothdirectories.The comparison is recursive&nbsp;- if there are any subdirectories,<EMCLASS="emphasis">dircmp</EM> checks those, too.</P><PCLASS="para">&#13;The <EMCLASS="emphasis">dircmp -s</EM> option stops the &quot;identical file&quot; messages.Use <EMCLASS="emphasis">-d</EM> to run <EMCLASS="emphasis">diff</EM> on files that are different;<EMCLASS="emphasis">dircmp</EM> prints a new page for each <EMCLASS="emphasis">diff</EM> it runs:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>dircmp -d -s a b</B></CODE>Sep 16 09:35 1991  a only and b only Page 1   ...Sep 16 09:35 1991  Comparison of a b Page 1   ...Sep 16 09:35 1991  diff of ./pqp.help in a and b Page 13c3,4&lt; -#    &quot;Only this printer&quot;... 'pqp -3' would print on #3.--&gt; -#    &quot;Only this printer&quot;... 'pqp -3' would print only on #3;&gt;       other printer queues will be held.   ...</PRE></BLOCKQUOTE></P><PCLASS="para">The designers assumed you'd want to send the output to a printer.I usually read it on my screen with the<ACLASS="indexterm"NAME="AUTOID-17716"></A><SPANCLASS="link"><EMCLASS="emphasis">less</EM> (<ACLASS="linkend"HREF="ch25_04.htm"TITLE='The "less&quot; Pager: More than "more&quot;'>25.4</A>)</SPAN>pager and its <EMCLASS="emphasis">-s</EM> option, which squeezes out the multiple blank lines.If you don't have <EMCLASS="emphasis">less</EM> or <EMCLASS="emphasis">more -s</EM>, try piping the outputthrough<SPANCLASS="link"><EMCLASS="emphasis">cat -s</EM> (<ACLASS="linkend"HREF="ch25_10.htm"TITLE="Squash Extra Blank Lines ">25.10</A>)</SPAN>or<SPANCLASS="link">a <EMCLASS="emphasis">sed</EM> filter (<ACLASS="linkend"HREF="ch34_18.htm"TITLE="Multiline Delete ">34.18</A>)</SPAN>.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <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="ch16_21.htm"TITLE="16.21 Finding All Directories with the Same Name "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 16.21 Finding All Directories with the Same Name "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="ch16_23.htm"TITLE="16.23 Comparing Filenames in Two Directory Trees "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 16.23 Comparing Filenames in Two Directory Trees "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">16.21 Finding All Directories with the Same Name </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">16.23 Comparing Filenames in Two Directory Trees </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 + -