Ever wanted to know how much longer your cp -r
needs? This little Ruby script might help you.
$ cp2 coderay coderay-0.8
From: 307M coderay
To: 154M coderay-0.8
The second line updates every second while copying. It’s fast enough on OS X, but I’m sure it can be optimized.
Here’s the code:
#!/usr/bin/env ruby puts <<USAGE unless ARGV.size == 2 cp progress printer (public domain) Usage: cp2 FROM TO USAGE from, to = *ARGV puts "From: " + `du -sh #{from}` copy = Thread.new { `cp -r #{from} #{to}` } $stdout.sync = true loop do sleep 1 print "\rTo: ", `du -sh #{to}`.chomp break unless copy.alive? end copy.join puts