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

📄 331-334.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Special Edition Using Linux, Fourth Edition:Managing Files and Directories</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0789717468//-->

<!--TITLE=Special Edition Using Linux, Fourth Edition//-->

<!--AUTHOR=Jack Tackett//-->

<!--AUTHOR=Jr.//-->

<!--AUTHOR=Steve Burnett//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Que//-->

<!--CHAPTER=17//-->

<!--PAGES=331-334//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="329-331.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ch18/335-339.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>You can use <TT>touch</TT> to fool a command that checks for dates. For example, if your system runs a backup command that backs up only files modified after a particular date, you can touch a file that hasn&#146;t been changed recently to make sure that it&#146;s picked up.</P>

<P>The <TT>touch</TT> command has the following three flags that you can use to modify its default behavior:</P>

<CENTER>

<TABLE WIDTH="90%"><TR>

<TD WIDTH="15%" ALIGN="LEFT"><TT>-a</TT>

<TD WIDTH="85%" ALIGN="LEFT">Updates only the file&#146;s access date and time stamp

<TR>

<TD><TT>-m</TT>

<TD>Updates only the file&#146;s modification date and time stamp

<TR>

<TD><TT>-c</TT>

<TD>Prevents <TT>touch</TT> from creating a file if it doesn&#146;t already exist

</TABLE>

</CENTER>

<P>The default syntax for <TT>touch</TT> is <TT>touch -am <I>filelist</I></TT>.</P>

<H3><A NAME="Heading15"></A><FONT COLOR="#000077">Compressing Files</FONT></H3>

<P>If space is tight on a system or you have large ASCII files that aren&#146;t used often, you can reduce the size of the files by compressing them. The standard Linux utility for compressing files is <TT>gzip</TT>. The <TT>gzip</TT> command can compress an ASCII file by as much as 80 percent. Most UNIX systems also provide the command <TT>compress</TT>, which typically is used with <TT>tar</TT> to compress groups of files for an archive. A file compressed with the <TT>compress</TT> command ends with a <TT>.Z</TT> extension&#151;for example, archive1.tar.Z. Red Hat&#146;s distribution also provides the <TT>zip</TT> and <TT>unzip</TT> programs for compressing and archiving lists of files.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>TIP:&nbsp;&nbsp;</B>It&#146;s a good idea to compress a file before you mail it or back it up.<HR></FONT>

</BLOCKQUOTE>

<P>If a file is successfully compressed with the command <TT>gzip <I>filename</I></TT>, the compressed file is named <I>filename</I>.gz, and the original file is deleted. To restore the compressed file to its original components, use the <TT>gunzip <I>filename</I></TT> command.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B>You don&#146;t have to append the .gz to the filename when you uncompress a file. The .gz extension is assumed by the gunzip command.<HR></FONT>

</BLOCKQUOTE>

<P>If you want to keep the file in its compressed form but want to pipe the data to another command, use the <TT>zcat</TT> command. The <TT>zcat</TT> command works just like the <TT>cat</TT> command but requires a compressed file as input. <TT>zcat</TT> decompresses the file and then prints it to the standard output device.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR>&#149; <B>See</B> &#147;Connecting Processes with Pipes,&#148; <B>p. 355</B><HR></FONT>

</BLOCKQUOTE>

<P>For example, if you&#146;ve compressed a list of names and addresses stored in a file named namelist, the compressed file is named namelist.gz. If you want to use the contents of the compressed file as input to a program, use the <TT>zcat</TT> command to begin a pipeline, as follows:</P>

<!-- CODE SNIP //-->

<PRE>

zcat namelist | <I>program1</I> | <I>program2</I> &#133;

</PRE>

<!-- END CODE SNIP //-->

<P><TT>zcat</TT> suffers from the same limitation <TT>cat</TT> does: It can&#146;t go backward within a file. Linux offers a program called <TT>zless</TT> that works just like the <TT>less</TT> command, except <TT>zless</TT> operates on compressed files. The same commands that work with <TT>less</TT> also work with <TT>zless</TT>.</P>

<P>The <TT>compress</TT> command&#146;s legal status is in limbo; someone has claimed patent infringement. The compression program of choice for Linux is the freely distributed compression utility <TT>gzip</TT>. The <TT>gzip</TT> command has none of the potential legal problems of <TT>compress</TT>, and almost all the files installed by Linux that are compressed were compressed with <TT>gzip</TT>. <TT>gzip</TT> should work with most compressed files, even those compressed with the older <TT>compress</TT> program.</P>

<P>For those of you familiar with PKWARE&#146;s PKZIP line of products, you can use the <TT>zip</TT> and <TT>unzip</TT> programs provided with the Red Hat distribution. The <TT>zip</TT> command compresses several files and stores them in an archive, just like PKZIP. The <TT>unzip</TT> command extracts files from an archive. See the man pages for <TT>zip</TT> and <TT>unzip</TT> for more information.</P>

<H3><A NAME="Heading16"></A><FONT COLOR="#000077">From Here&#133;</FONT></H3>

<P>Managing files and utilities in Linux is a relatively simple chore. Organizing files into directories is easy. Finding, moving, copying, renaming, and deleting files and directories are simple with the commands <TT>find</TT>, <TT>mv</TT>, <TT>cp</TT>, and <TT>rm</TT>. For more information, see the following:</P>

<DL>

<DD><B>&#149;</B>&nbsp;&nbsp;Chapter 14, &#147;Managing File Systems,&#148; which discusses practices for keeping your file system under control.

<DD><B>&#149;</B>&nbsp;&nbsp;The man pages for the various commands discussed in this chapter: <TT>ls</TT>, <TT>mkdir</TT>, <TT>mv</TT>, <TT>cp</TT>, <TT>rm</TT>, <TT>rmdir</TT>, <TT>cat</TT>, <TT>less</TT>, <TT>more</TT>, <TT>find</TT>, <TT>touch</TT>, <TT>gzip</TT>, <TT>compress</TT>, <TT>tar</TT>, <TT>zip</TT>, and <TT>unzip</TT>.

</DL>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="329-331.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ch18/335-339.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -