cp或mv時 顯示狀態 - BBS
By Leila
at 2010-05-04T13:51
at 2010-05-04T13:51
Table of Contents
※ 引述《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% [===========================================> ]
--
情子.....我是劉穿峰
--
: 我想問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% [===========================================> ]
--
情子.....我是劉穿峰
--
Tags:
BBS
All Comments
Related Posts
cp或mv時 顯示狀態
By Isla
at 2010-05-03T23:12
at 2010-05-03T23:12
用Packet Filter(PF) 做 IP mapping 遇 …
By Iris
at 2010-05-03T17:31
at 2010-05-03T17:31
【05/04 TOSSUG 心得分享】Thinker - SVG + Gecko 完全攻略
By Anonymous
at 2010-05-01T23:59
at 2010-05-01T23:59
cp或mv時 顯示狀態
By Frederic
at 2010-05-01T07:37
at 2010-05-01T07:37
用Packet Filter(PF) 做 IP mapping 遇 …
By Edith
at 2010-05-01T05:38
at 2010-05-01T05:38