theshell.ch/site/pages/fs/cp.html
bevilj 8378ae0a4e interm, fs: fix new added pages
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@279 a672b425-5310-4d7a-af5c-997e18724b81
2018-11-19 14:57:49 +00:00

53 lines
2.1 KiB
HTML

---
layout: page
category-page: fs
category-title: FileSystem
tags: directory list copy cp
author: Mattia Hijman
title: cp
previous-page: pages/fs/cd.html
previous-next: pages/fs/du.html
---
The <code>cp</code> command copies the contents of one or more files or directories to a
target file or directory.<br>
<pre>
cp [source1] [source2] [source3] ... [target]
</pre>
<h3>Flags</h3>
<ul>
<li><b>-a</b>: Same as -pPR options. Preserves structure and attributes of files
but not directory structure.
</li>
<li><b>-f</b>: If the destination file cannot be opened, remove it and create a new file,
without prompting for confirmation regardless of its permissions.
The target file is not unlinked before the copy,
so any existing access rights will be retained.
</li>
<li><b>-H</b>: If -R is specified, symbolic links on the command line are followed.</li>
<li><b>-i</b>: Cause cp to write a prompt to the standard error output before
copying a file that would overwrite an existing file. If the
response from the standard input begins with the character <i>y</i> or
<i>Y</i>, the file copy is attempted.
</li>
<li><b>-L</b>: If the -R option is specified, all symbolic links are followed.</li>
<li><b>-n</b>: Do not overwrite an existing file.</li>
<li><b>-P</b>: If the -R option is specified, no symbolic links are followed.</li>
<li><b>-p</b>: Cause cp to preserve the following attributes of each source file
in the copy.
</li>
<li><b>-R</b>: If source_file designates a directory, cp copies the directory and
the entire subtree connected at that point. If the source_file
ends in a /, the contents of the directory are copied rather than
the directory itself. This option also causes symbolic links to be
copied, rather than indirected through, and for cp to create special files
rather than copying them as normal files.
</li>
<li><b>-v</b>: Cause cp to be verbose, showing files as they are copied.</li>
<li><b>-X</b>: Do not copy Extended Attributes (EAs) or resource forks.</li>
</ul>