Re:Can you get cp to give a progress bar like wget?
by panic on Thursday March 04, 2010 @05:17AM
(#1166569)
Easier: install Pipe Viewer (http://www.ivarch.com/programs/pv.shtml) and, instead of
run
[ Parent
| on HN ]
Re:Can you get cp to give a progress bar like wget?
by __david__ on Thursday March 04, 2010 @06:50AM
(#1166666)
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.
Re:Can you get cp to give a progress bar like wget?
by philjackson on Thursday March 04, 2010 @06:48AM
(#1166663)
I like pv and find myself using it when bziping large files (where the blocker is bzip). It must have a negative impact on the speed of a copy.
*Hmmm, I can't back up my own predictions:
cp huge blah 0.11s user 7.94s system 6% cpu 2:12.54 total
pv < huge > something 0.12s user 8.10s system 7% cpu 1:54.86 total
Re:Can you get cp to give a progress bar like wget?
by w1ntermute on Thursday March 04, 2010 @12:38PM
(#1167471)
For those of you interested in making it a permanent replacement for cp, you can use this Python script:
#!/usr/bin/env python
from sys import argv
from subprocess import Popen
copy_from = open(argv[-2],'r')
copy_to = open(argv[-1],'w')
Popen("pv", stdin=copy_from, stdout=copy_to)
copy_from.close()
copy_to.close()
Just alias cp to it in Bash.
Re:Can you get cp to give a progress bar like wget?
by rntz on Thursday March 04, 2010 @01:01PM
(#1167535)
Alternatively, you could just write a shell function:
cp() { pv < $1 > $2; }
(Or name the function something else if you want regular cp still available.)
Re:Can you get cp to give a progress bar like wget?
by olliesaunders on Thursday March 04, 2010 @01:58PM
(#1167711)
Quote the variables.
Re:Can you get cp to give a progress bar like wget?
by rntz on Friday March 05, 2010 @03:22PM
(#1170388)
Ah, good point. I'm personally used to zsh, which doesn't have that particular misfeature.
Re:Can you get cp to give a progress bar like wget?
by ajross on Thursday March 04, 2010 @12:46PM
(#1167493)
Um... in what universe would you want an interactive terminal gadget to become the default implementation of cp? Yikes.
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.
Re:Can you get cp to give a progress bar like wget?
by philjackson on Thursday March 04, 2010 @01:48PM
(#1167683)
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.
Re:Can you get cp to give a progress bar like wget?
by petercooper on Friday March 05, 2010 @12:13AM
(#1168883)
Mac users will be happy to learn that:
sudo port install pv
"just works" :-) (Well, assuming you use MacPorts anyway.)