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

📄 cp.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
Any write errors will cause<i>cp</i>to write a diagnostic message to standard error andcontinue to step 3e.<p><li>The file descriptor will be closed.<p><li>The<i>cp</i>utility will do nothing more with<i>source_file.</i>If a write error occurred in step 3d, it is unspecified if<i>cp</i>continues with any remaining files.If no write error occurred in step 3d,<i>cp</i>will go on to any remaining files.<p></ol><p><li>Otherwise, the following steps will be taken:<ol type = a><p><li>If the<b>-r</b>option was specified, the behaviour is implementation-dependent.<br><p><li>If the<b>-R</b>option was specified, the following steps will be taken:<ol type = i><p><li>The<i>dest_file</i>will be created with the same file type as<i>source_file</i>.<p><li>If<i>source_file</i>is a file of type FIFO,the file permission bits will be the same as those of<i>source_file,</i>modified by the file creation mask of the user if the<b>-p</b>option was not specified.Otherwise, the permissions, owner ID and group ID of<i>dest_file</i>are implementation-dependent.<p>If this creation fails for any reason,<i>cp</i>will write a diagnostic message to standard error, do nothing more with<i>source_file</i>and go on to any remaining files.<p></ol><p></ol><p></ol><p>If the implementation provides additional oralternate access control mechanisms(see<b>file access permissions</b>inthe <b>XBD</b> specification, <a href="../xbd/glossary.html"><b>Glossary</b>&nbsp;</a> ),their effect on copies of files is implementation-dependent.</blockquote><h4><a name = "tag_001_014_190">&nbsp;</a>OPTIONS</h4><blockquote>The<i>cp</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b>&nbsp;</a> .<p>The following options are supported:<dl compact><dt><b>-f</b><dd>If a file descriptor for a destination file cannot be obtained,as described in step 3.a.ii.,attempt to unlink the destination file and proceed.<dt><b>-i</b><dd>Write a prompt to standard error before copying toany existing destination file.If the response from the standard inputis affirmative, the copy will be attempted, otherwise not.<dt><b>-p</b><dd>Duplicate the following characteristics of each source file inthe corresponding destination file:<ol><li>The time of last data modification and time of last access.If this duplication fails for any reason,<i>cp</i>will write a diagnostic message to standard error.<li>The user ID and group ID.If this duplication fails for any reason, it is unspecified whether<i>cp</i>writes a diagnostic message to standard error.<li>The file permission bits and the S_ISUID and S_ISGID bits.Other, implementation-dependent, bits may be duplicated as well.If this duplication fails for any reason,<i>cp</i>will write a diagnostic message to standard error.</ol>If the user ID or the group ID cannot be duplicated, thefile permission bits S_ISUID and S_ISGID will be cleared.If these bits are present in the source file but are notduplicated in the destination file, it is unspecified whether<i>cp</i>writes a diagnostic message to standard error.The order in which the precedingcharacteristics are duplicated is unspecified.The<i>dest_file</i>will not be deleted if thesecharacteristics cannot be preserved.<dt><b>-R</b><dd>Copy file hierarchies.<dt><b>-r</b><dd>Copy file hierarchies.The treatment of special files is implementation-dependent.</dl></blockquote><h4><a name = "tag_001_014_191">&nbsp;</a>OPERANDS</h4><blockquote>The following operands are supported:<dl compact><dt><i>source_file</i><dd>A pathname of a file to be copied.<dt><i>target_file</i><dd>A pathname of an existing or non-existing file,used for the output when a single file is copied.<dt><i>target</i><dd>A pathname of a directory to contain the copied files.</dl></blockquote><h4><a name = "tag_001_014_192">&nbsp;</a>STDIN</h4><blockquote>Used to read an input line in response to each promptspecified in the STDERR section.Otherwise, the standard input will not be used.</blockquote><h4><a name = "tag_001_014_193">&nbsp;</a>INPUT FILES</h4><blockquote>The input files specified as operands may be of any file type.</blockquote><h4><a name = "tag_001_014_194">&nbsp;</a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>cp</i>:<dl compact><dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_COLLATE</i><dd>Determine the locale for thebehaviour of ranges, equivalence classesand multi-character collating elementsused in the extended regular expression defined for the<b>yesexpr</b>locale keyword in the LC_MESSAGES category.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text data ascharacters (for example, single- as opposed to multi-byte charactersin arguments and input files) andthe behaviour of character classesused in the extended regular expression defined for the<b>yesexpr</b>locale keyword in the LC_MESSAGES category.<dt><i>LC_MESSAGES</i><dd>Determine the locale for the processing of affirmative responsesthat should be used to affectthe format and contents of diagnosticmessages written to standard error.<dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i></dl></blockquote><h4><a name = "tag_001_014_195">&nbsp;</a>ASYNCHRONOUS EVENTS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_196">&nbsp;</a>STDOUT</h4><blockquote>Not used.</blockquote><h4><a name = "tag_001_014_197">&nbsp;</a>STDERR</h4><blockquote>A prompt will be written to standard error under the conditionsspecified in the DESCRIPTION section.The prompt will contain the destinationpathname, but its format is otherwise unspecified.Otherwise, the standard error will be used only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_198">&nbsp;</a>OUTPUT FILES</h4><blockquote>The output files may be of any type.</blockquote><h4><a name = "tag_001_014_199">&nbsp;</a>EXTENDED DESCRIPTION</h4><blockquote>None.<br></blockquote><h4><a name = "tag_001_014_200">&nbsp;</a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>All files were copied successfully.<dt>&gt;0<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_201">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>If<i>cp</i>is prematurely terminated by a signal or error, files orfile hierarchies may be only partially copied and files anddirectories may have incorrect permissions or access and modification times.</blockquote><h4><a name = "tag_001_014_202">&nbsp;</a>APPLICATION USAGE</h4><blockquote>The difference between<b>-R</b>and<b>-r</b>is in the treatment by<i>cp</i>of file types other than regular and directory.The original<b>-r</b>flag, forhistoric reasons, does not handle special files any differently fromregular files, but always reads the file and copies its contents.This has obvious problems in the presence of special file types,for example character devices, FIFOs and sockets.The<b>-R</b>option is intended to recreate the file hierarchy and the<b>-r</b>option supports historical practice.It is anticipated that a future issue ofthis specification will deprecate the<b>-r</b>option, and for thatreason, there has been no attempt to fix its behaviour with respectto FIFOs or other file types where copying the file is clearly wrong.However, some systems support<b>-r</b>with the same abilities as the<b>-R</b>defined in the ISO/IEC 9945-2:1993 standard.To accommodate them as well as systems that do not,the differences between<b>-r</b>and<b>-R</b>are implementation-dependent.Implementations may make them identical.<p>The set-user-ID and set-group-ID bits are explicitlycleared when files are created.This is to prevent users fromcreating programs that are set-user-ID orset-group-ID to them when copying filesor to make set-user-ID orset-group-ID files accessible to new groups of users.For example, if a file is set-user-ID and the copy has a different group IDthan the source, a new group of users has execute permission toa set-user-ID program than did previously.In particular, this is aproblem for superusers copying users' trees.</blockquote><h4><a name = "tag_001_014_203">&nbsp;</a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_204">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>The<b>-r</b>option may be removed; use<b>-R</b>instead.</blockquote><h4><a name = "tag_001_014_205">&nbsp;</a>SEE ALSO</h4><blockquote><i><a href="mv.html">mv</a></i>,<i><a href="find.html">find</a></i>,<i><a href="ln.html">ln</a></i>,<i><a href="pax.html">pax</a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX &reg; is a registered Trademark of The Open Group.<br>Copyright &copy; 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>

⌨️ 快捷键说明

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