I love pv. It's great because it's pretty much a drop-in for "cat" that gives you fancy progress bars. But for copy I tend to use "rsync -aP". It has progress but not a bar and just feels more like a replacement for cp to me.
What? I think the override is fine in an interactive environment.
My team and I use a hack which overrides cd and as well as calling builtin cd it sources a script if it exists from cwd. This means you can get the exact enviroment you need for that working copy of a project.
That doesn't give you a progress bar because it doesn't know how big the data stream will be. You need to pass in some options to pv to give it that information.
size=`wc -c a` ; cp a b & sleep 1 ; ETA 'wc -c b' $size
Every 10 seconds it runs the given command, then gives an ETA to the number you want. It's not a progress bar, but it is a projected time of completion and can easily be extended if you want.
ETA is like pv but for those occasions when you don't have access to the data stream in a pipe. It can be used anytime you can compute a number that indicates how far along you are. Just give it the command to run for itself, or run the command and feed the values to ETA on stdin and it will give you regular estimates of when it will hit the given target.
It also lets your cp run at full speed, unlike when you copy through pv, and is more generic than just checking on the progress of specifically a copy command. It lets you predict the completion time of anything measurable.
I use rsync -avzP exclusively now over cp ever since I tried copying ~7000 files from a USB drive and found cp choked less than 10% through. rsync is wonderful.
On some BSDs (including Mac OS X) there is a signal, SIGINFO, to which cp will respond by printing out a status report. You can send this signal by typing ^T.
34 comments
[ 2.5 ms ] story [ 76.8 ms ] thread*Hmmm, I can't back up my own predictions:
Still, nice pointer to the pv tool, which I hadn't heard of.
Still still, the linked awk snipped is awfully clever and more fun to read.
My team and I use a hack which overrides cd and as well as calling builtin cd it sources a script if it exists from cwd. This means you can get the exact enviroment you need for that working copy of a project.
cp $SOURCE /dev/stdout | pv | cp /dev/stdin $DEST
Edit: "pv <a >b" is simpler, but isn't the game to fit "cp" somewhere? :)
http://news.ycombinator.com/item?id=1149364
ETA is like pv but for those occasions when you don't have access to the data stream in a pipe. It can be used anytime you can compute a number that indicates how far along you are. Just give it the command to run for itself, or run the command and feed the values to ETA on stdin and it will give you regular estimates of when it will hit the given target.
It also lets your cp run at full speed, unlike when you copy through pv, and is more generic than just checking on the progress of specifically a copy command. It lets you predict the completion time of anything measurable.
http://news.ycombinator.com/item?id=1151791
I was thinking of slowing the copy operation down a bit more by roundtripping it through Australia...
In the BUGS section of the man page you can find these items (amongst others):
Hmm. That's useful to note. I can understand that, although it could be surprising in practice for the unwary. Understandable. That's definitely worth knowing. Damn.But of course, nothing is stopping you from commenting this check out.