作者ARD33 (runlevel)
看板FreeBSD
标题Re: [问题] cp或mv时 显示状态
时间Tue May 4 13:51:48 2010
※ 引述《slinbody (不败地球人)》之铭言:
: 我想问bsd下
: 有没有可以取代cp或mv而且可以显示工作进度的软体
: 常常再搬移大档案时 一按enter就要等很久
: 像window贴上时 都会有个目前进度(虽然剩余时间不太准)
: 唯一想到的 就是用ftp在local上般
: 不知道有没有人有什麽好主意??
http://chris-lamb.co.uk/2008/01/24/can-you-get-cp-to-give-a-progress-bar-like-wget/
#!/bin/sh
cp_p()
{
strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
| awk '{
count += $NF
if (count % 10 == 0) {
percent = count / total_size * 100
printf "%3d%% [", percent
for (i=0;i<=percent;i++)
printf "="
printf ">"
for (i=percent;i<100;i++)
printf " "
printf "]\r"
}
}
END { print "" }' total_size=$(stat -c '%s' "${1}") count=0
}
In action:
% cp_p /mnt/raid/pub/iso/debian/debian-2.2r4potato-i386-netinst.iso /dev/null
76% [===========================================> ]
--
情子.....我是刘穿峰
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 111.240.211.245