Browse Source

cp.md: major overhaul

- change "directory" to "folder" (more beginner-friendly)
- use an extension to distinguish file paths from folder paths
- reword some of the descriptions for clarity
- include examples to clarify when the target argument defines the actual copy, and when it defines the folder where to put the copy
- add an example to copy contents of a folder into another (existing) folder
Waldir Pimenta 8 years ago
parent
commit
da10202a3d
1 changed files with 19 additions and 11 deletions
  1. 19 11
      pages/common/cp.md

+ 19 - 11
pages/common/cp.md

@@ -1,27 +1,35 @@
 # cp
 
-> Copy files.
+> Copy files and folders.
 
-- Copy files in arbitrary locations:
+- Copy a file to another location:
 
-`cp {{/path/to/original}} {{/path/to/copy}}`
+`cp {{/path/to/file.ext}} {{/path/to/copy.ext}}`
 
-- Copy a file to a parent directory:
+- Copy a file into another folder, keeping the filename:
 
-`cp {{/path/to/original}} ../{{path/to/copy}}`
+`cp {{/path/to/file.ext}} {{path/to/target/parent/folder}}`
 
-- Copy directories recursive using the option -r:
+- Copy a folder recursively to another location:
 
-`cp -r {{/path/to/original}} {{/path/to/copy}}`
+`cp {{/path/to/folder}} {{/path/to/copy}}`
 
-- Show files as they are copied:
+- Copy a folder recursively into another folder, keeping the folder name:
 
-`cp -vr {{/path/to/original}} {{/path/to/copy}}`
+`cp -r {{/path/to/folder}} {{/path/to/target/parent/folder}}`
 
-- Make a copy of a file, adding an extension:
+- Copy a folder recursively, in verbose mode (shows files as they are copied):
+
+`cp -vr {{/path/to/folder}} {{/path/to/copy}}`
+
+- Copy the contents of a folder into another folder:
+
+`cp -r {{/path/to/source/folder/*}} {{/path/to/target/folder}}`
+
+- Copy of a file adding an extension:
 
 `cp {{file.html}}{,.backup}`
 
-- Make a copy of a file, changing the extension:
+- Copy a file, changing the extension:
 
 `cp {{file.}}{html,backup}`