In this first example, we will copy the only directory. We can just provide the source directory and destination directory names to the cp command. In this example, we will try to copy a single directory. As we can see we get an error like below.
Now here is the real scenario. We will copy our directory named backup with a new named newbackup. We will use the -r option which makes copy operation recursively. Recursive means subdirectories and files will be copied too.
保留源目录属性时复制 (Copy While Preserving Source Directory Attributes)
Files and directories provide some attributes in Linux operating systems. These attributes are file mode, ownership, timestamp, context, links, xattr, etc. During directory copy, we can copy these attributes too with the -a option like below.
将整个目录复制到当前用户的主目录(Copy Entire Directory To The Current User Home Directory)
Linux bash shell provides some shortcuts about the paths. If we want to copy a directory completely into the current user home directory we can ~ tilde to specify the user home directory path. In this example, we will copy the directory named backup to the current user home directory.
Linux bash shell提供了一些有关路径的快捷方式。 如果要将目录完全复制到当前用户主目录中，可以~波浪号指定用户主目录路径。 在此示例中，我们将名为backup的目录复制到当前用户主目录。
使用rsync命令复制整个目录(Copy Entire Directory with rsync Command)
rsync is very popular and useful tools used to copy, sync, and backup files and directories. We can use rsync in order to copy the complete directory with its subdirectories locally or to the remote systems. We will use -r options to copy all directories and files recursively and also use -v option for verbose output.
mac 命令行 复制目录Copying a directory for the sake of backupissomething I do often, especially when I'm trying to figure out why something isn't working when I use an external library. I'll copy the ...
mac 命令行 复制目录
Copying a directory for the sake of backup is something I do often, especially when I'm trying to figure out why something isn't working when I use an external library. I'll copy the directory structure as a backup, mess around with the original source until I find a solution, then restore the original and change my overall system code to bring in my revised version.