bob*_*bby 7 linux bash command-line-interface cp copying
我正在磁盘之间复制大量文件。大约有 16 GB 的数据。我想从命令行查看进度信息,甚至估计完成时间。
有什么建议吗?
使用rsync --human-readable --progress
.
对于单个文件和块设备,还有pv
. 如果你真的需要一个准确的进度条,尝试使用tar
pv —— 像这样:
source=/the/source/directory
target=/the/target/directory
size=$(du -sx "$source")
cd "$source"
find . xdev -depth -not -path ./lost+found -print0 \
| tar --create --atime-preserve=system --null --files-from=- \
--format=posix --no-recursion --sparse \
| pv --size ${size}k \
| { cd "$target"; \
tar --extract --overwrite --preserve-permissions --sparse; }
Run Code Online (Sandbox Code Playgroud)
但是请注意,GNUtar
尚不支持 ACL 或扩展属性,因此如果您要复制使用“acl”或“xattrs”选项挂载的文件系统,则需要使用 rsync(使用“ --acls
”和“ --xattrs
”选项)。就个人而言,我使用:
rsync --archive --inplace --hard-links --acls --xattrs --devices --specials \
--one-file-system --8-bit-output --human-readable --progress /source /target
Run Code Online (Sandbox Code Playgroud)
还要查看您是否要使用--delete
和/或--numeric-ids
选项。