Ada*_*dam 4 permissions cp macos
我想复制修改和访问时间,而不是用户 ID。如果我使用
cp -p source target
Run Code Online (Sandbox Code Playgroud)
它会复制一切。
我正在尝试将文件复制到其他用户,但保持原始日期不变。
从cp
手册GNU coreutils
:
-p
与...一样--preserve=mode,ownership,timestamps
所以,你正在寻找
cp --preserve=mode,timestamps source target
Run Code Online (Sandbox Code Playgroud)
但是如果您使用一些非 GNU 操作系统,您可能无法将这些长选项与cp
. 在这种情况下,您可以rsync
尝试一下,您可以在其中详细指定应保留哪些属性(在手册页中搜索“保留”):
-H, --hard-links preserve hard links
-p, --perms preserve permissions
-E, --executability preserve executability
-A, --acls preserve ACLs (implies -p)
-X, --xattrs preserve extended attributes
-o, --owner preserve owner (super-user only)
-g, --group preserve group
--devices preserve device files (super-user only)
--specials preserve special files
-t, --times preserve modification times
Run Code Online (Sandbox Code Playgroud)
因此,要类似于cp
上面的命令,请使用类似
rsync -pEt source target
Run Code Online (Sandbox Code Playgroud)
要预先测试命令,您可以使用-n
. 还添加详细参数-v
以查看发生了什么:
rsync -nv -pEt source target
Run Code Online (Sandbox Code Playgroud)
但是,我不确定访问时间是否也会被复制。
归档时间: |
|
查看次数: |
7801 次 |
最近记录: |