gpt4 book ai didi

macos - OSX 上的 cp 和 ditto 命令有什么区别?

转载 作者:行者123 更新时间:2023-12-02 02:01:14 24 4
gpt4 key购买 nike

我想知道 OSX 上 cp 和 ditto 命令之间的确切区别是什么?

这两个命令的主要区别是什么?

最佳答案

实际上手册页中的标题描述了差异:

  • cp - 复制文件和目录

  • 同上 - 复制目录层次结构,创建和提取文件

手册页中的更多信息

  • cp
cp [OPTION]... [-T] SOURCE DEST

cp [OPTION]... SOURCE... DIRECTORY

cp [OPTION]... -t DIRECTORY SOURCE...

Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

  • 同上
ditto [-v] [-V] [-X] [<options>] src ... dst_directory.

ditto [-v] [-V] [<options>] src_file dst_file

ditto -c [-z | -j | -k] [-v] [-V] [-X] [<options>] src dst_archive

ditto -x [-z | -j | -k] [-v] [-V] [<options>] src_archive ...
dst_directory

In its first form, ditto copies one or more source files or directories to a destination directory. If the destination directory does not exist it will be created before the first source is copied. If the destination directory already exists then the source directories are merged with the previous contents of the destination.

In its second form, ditto copies a file to the supplied dst_file path- name.

The next two forms reflect ditto's ability to create and extract ar- chives. These archives can be either CPIO format (preferred for unix content) or PKZip (for Windows compatibility). src_archive (and dst_archive) can be the single character '-', causing ditto to read (write) archive data from stdin (or to stdout, respectively).

ditto follows symbolic links provided as arguments but does not follow any links as it traverses the source or destination hierarchies. ditto overwrites existing files, symbolic links, and devices in the destination when these are copied from a source. The resulting files, links, and devices will have the same mode, access time, modification time, owner, and group as the source items from which they are copied. Pipes, sock- ets, and files with names beginning with .nfs or .afpDeleted will be ignored. ditto does not modify the mode, owner, group, extended attributes, or ACLs of existing directories in the destination. Files and symbolic links cannot overwrite directories or vice-versa.

ditto can be used to "thin" Universal Mach-O binaries during a copy. ditto can also copy files selectively based on the contents of a BOM ("Bill of Materials") file. ditto preserves file hard links (but not directory hard links) present in the source directories and preserves setuid and setgid modes when run as the superuser.

ditto will preserve resource forks and HFS meta-data information when copying unless instructed otherwise using --norsrc . Similarly, ditto will preserve extended attributes and Access Control Lists (ACLs) unless --noextattr or --noacl is passed. DITTONORSRC can be set in the environ- ment as an alias to --norsrc --noextattr --noacl on the command line.

关于macos - OSX 上的 cp 和 ditto 命令有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40974029/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com