News for hackers. Stuff that matters.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by danieldk on Saturday July 12, 2014 @07:28AM (#8024285)
Slightly related: what many people don't know is that on OS X and BSDs, commands often react to SIGINFO (Ctrl-t), giving progress information. E.g. from the cp man page:

     If cp receives a SIGINFO (see the status argument for stty(1)) signal,
     the current input and output file and the percentage complete will be
     written to the standard output.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by ak217 on Saturday July 12, 2014 @04:59PM (#8025771)
Very cool. Is there a reason why Linux tools don't react to SIGINFO, other than just "not implemented"?
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by na85 on Saturday July 12, 2014 @07:47PM (#8026138)
As far as I'm aware, Linux tools do react to various signals, just not SIGINFO because it comes from BSD and Linux just doesn't use that particular signal.

You can check dd progress by sending USR1, for example.

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by ak217 on Sunday July 13, 2014 @12:29AM (#8026650)
I just wish there was a control sequence keystroke like Ctrl+I to get programs to do that.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by ramidarigaz on Saturday July 12, 2014 @12:19PM (#8024936)
dd has a similar feature, but with SIGUSR (kill -USR1), and it works on Linux too.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by ysangkok on Saturday July 12, 2014 @01:49PM (#8025238)
How do you fire that signal from the console ?
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by koenigdavidmj on Saturday July 12, 2014 @03:53PM (#8025622)

  pkill -USR1 dd
You'll need to use ps to get the pid if you've got multiple dd instances running, and you'll of course need to run that as root if your dd instance is running as root.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by spoiler on Saturday July 12, 2014 @02:17PM (#8025325)
By using

    kill -s <Signal> <Process ID>
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by akshatpradhan on Saturday July 12, 2014 @08:34PM (#8026217)
Personally, I think the experience of typing ctrl+t is better than using pkill. Just 2 keyboard taps and you're done.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by jamescun on Saturday July 12, 2014 @06:23AM (#8024180)
For a verbose or simple progress `cp` equivalent I tend to use RSync. Both RedHat/CentOS/etc and Debian/Ubuntu all come with RSync as standard. The only caveat is that I find RSync to be slightly slower than coreutils cp; however you do gain all the advantages of RSync if you then need to sync files across the network for example.

> rsync --progress <source> <destination>

> rsync --progress /home/me/music/*.mp3 /mnt/shared/music

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by to3m on Saturday July 12, 2014 @06:29PM (#8025972)
I've found Midnight Commander (https://www.midnight-commander.org/) good if you just need the progress bar. In fact, you get not just one, but TWO - one for the individual file, and one for the transfer as a whole. Perhaps I'm easily pleased, but I find this useful.

(It doesn't do all the rsync fanciness, but if you don't need that and/or you've got some unwieldy subset of files to transfer - a situation the GUI-style approach makes light work of - then it comes in handy.)

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by thejosh on Saturday July 12, 2014 @07:36AM (#8024295)
I also like -avh and --stats for rsync, I use rsync many times a day for transferring files and folders across networks. It's brilliant.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by zidar on Saturday July 12, 2014 @06:37AM (#8024195)
It is slightly slover, but one huge benifit is, that you get -P or --partial, which often ends up saving me lots of time.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by agumonkey on Saturday July 12, 2014 @04:51AM (#8024057)
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by fit2rule on Saturday July 12, 2014 @04:53AM (#8024063)
Yeah .. I think I prefer pv for all my cp progressbar needs .. keeps things light and simple, and is already onboard.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by __david__ on Saturday July 12, 2014 @05:06AM (#8024087)
I like pv, but I thought that it didn't work with "cp -r" (let alone mv)… Am I wrong?

It would be nice for cp and mv to just have built-in progress bars (only active in interactive mode, etc).

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by hrjet on Saturday July 12, 2014 @05:22AM (#8024103)
About 10 years back I tried to do this by defining terminal escape codes for this. I was also implementing a new terminal as a POC. Unfortunately didn't find the time to go beyond it.

Here's the POC if anyone would like to take it further: http://anthias.sourceforge.net/

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by fyrabanks on Saturday July 12, 2014 @05:41AM (#8024124)
pv is by no means a standard include. Also the obvious advantage here is being able to monitor progress for processes you didn't pipe to pv initially (e.g., forgot or didn't think it would be a long transfer).
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by zurn on Saturday July 12, 2014 @05:45AM (#8024133)
pv is just cat with a progress bar, so it only handles the case where you are copying a single big file.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by ithkuil on Saturday July 12, 2014 @06:31AM (#8024188)
Indeed. You can use it to show the progress of a recursive directory copy with this trick:

tar c -C /tmp/source . | pv | tar x -C /tmp/dest

you can also pass an approximated size of your source to pv, however the tar output will be slightly bigger.

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by ysangkok on Saturday July 12, 2014 @01:53PM (#8025251)
how would you estimate the size quickly? 'du' can take quite long
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by teraflop on Saturday July 12, 2014 @10:04PM (#8026399)
You can start pv without an estimated size, run du in the background, and then supply the estimate to pv once it's calculated using the '-R' (remote control) option.

A bit clumsy, but it shouldn't be hard to write a little script to do it.

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by ithkuil on Saturday July 12, 2014 @10:15PM (#8026417)
Cool, didn't know about that pv had a remote control.

Anyway, if cp -R had a progress bar it would behave the same way, i.e. it would have first to recursively stat the source the same way as du does, and only then it could start reporting a completion percentage.

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by abcd_f on Saturday July 12, 2014 @05:39AM (#8024121)
Using /proc is pretty damn clever! I thought it would be some sort of wrapper for strace, but your solution is so much simpler.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by adrusi on Saturday July 12, 2014 @07:05AM (#8024238)
Here's a single command which should do the same. It supports cp and dd, but anything else that supports SIGINFO could be added in.

    ps -A | grep -P 'cp|dd' | sed -r 's/^\s*([0-9]+).+$/\1/' | xargs kill -s SIGINFO
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by ars on Sunday July 13, 2014 @11:12AM (#8027521)
This assumes the command supports SIGINFO, but that's a BSD thing. Linux commands don't support that, so this is not a replacement.

And did you really just reinvent pkill?

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by nailer on Saturday July 12, 2014 @05:23AM (#8024104)
Off topic, hoe do I get a PS1 like those screenshots?
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by Zikes on Saturday July 12, 2014 @05:56AM (#8024147)
Looks just like vim's powerline/airline status bars. IIRC it takes a bit of font wrangling to get those chevron colors working right.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by diegolo on Saturday July 12, 2014 @08:44AM (#8024408)
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by oftenwrong on Saturday July 12, 2014 @06:51AM (#8024217)
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by justincormack on Saturday July 12, 2014 @05:07AM (#8024090)
dd has progress built in, under Linux it is kill -USR1 <pid> to get a progress report, the signal varies by OS. cp has a -v option, if tahts not enough rsync has a --progress option too that gives within file progress.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by skore on Saturday July 12, 2014 @02:25PM (#8025350)
If anybody is using dd to rescue a failing drive, I can very much recommend using the spectactular ddrescue instead.

I had a 2TB drive turn up five figure error rates (Raw Read Error rate ended up at 90k - when I started, it was already no longer possible to mount it, but it did show up in /dev) and thought I had lost an entire year of family pictures (mea culpa on not having a backup, of course). It took four months, 24/7 of meticulous work, but it ended up giving me a near perfect copy to an identical drive (save for ~20kb of truly dead sectors).

Amongst many other features, it has a logfile where it keeps track of the overall process - so that it can be killed or paused and restarted later.

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by midko on Saturday July 12, 2014 @06:44AM (#8024209)
To expand the parent comment, in Terminal (OS X), Ctrl-T prints the progress of dd and cp so you needn't look up their PIDs
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by scarygliders on Saturday July 12, 2014 @06:18AM (#8024177)
And dcfldd (not a coreutils app you have to install it separately) gives you a progress report, as well as using all the usual dd syntax.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by daw___ on Saturday July 12, 2014 @05:15AM (#8024100)
`cv` is a coreutils viewer, rsync is not included in coreutils.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by justincormack on Saturday July 12, 2014 @05:39AM (#8024120)
cv is not included in coreutils either, so I still have to install something.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by Nux on Saturday July 12, 2014 @04:46AM (#8024048)
Very nice! I should package this.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by stanzheng on Saturday July 12, 2014 @11:29AM (#8024787)
Anyone know a similar tool available to OSX or if its feasible to port or recreate this for MAC?

I'm not too familiar with what file libs or utils can be used to handle this as the author says this relies on a linux specific header file and tool.

See https://github.com/Xfennec/cv/issues/6

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by lobster_johnson on Saturday July 12, 2014 @11:59AM (#8024867)
Entirely feasible, as far as I know; OS X lets you discover processes and access their devices. OS X, being BSD-based, doesn't have a /proc file system; instead, you have to use sysctl() to get at the data.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by gaadd33 on Saturday July 12, 2014 @11:38AM (#8024811)
Just hit ctrl-t to get status on OS X.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by mef on Saturday July 12, 2014 @05:27PM (#8025832)
ctrl+t doesn't show percent complete
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by AdamGibbins on Saturday July 12, 2014 @11:15PM (#8026521)
Yes it does

  aeg@bigwibble ~/ % cp bigfile /Volumes/data_sd1
  load: 1.60  cmd: cp 17686 uninterruptible 0.00u 0.09s
  bigfile -> /Volumes/data_sd1/bigfile   1%
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by mef on Sunday July 13, 2014 @12:13PM (#8027752)
Here's me hitting it 4 times:

    [/tmp]$ cp bigfile bigfile2
    load: 1.78  cmd: gcp 93420 running 0.00u 0.04s
    load: 1.78  cmd: gcp 93420 running 0.00u 0.10s
    load: 1.80  cmd: gcp 93420 uninterruptible 0.00u 0.16s
    load: 1.80  cmd: gcp 93420 uninterruptible 0.00u 0.26s
    [/tmp]$
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by gaadd33 on Monday July 14, 2014 @08:55PM (#8034135)
What is gcp? It sounds like you have some alias setup for cp and that's interfering.

Try: /bin/cp bigfile bigfile2

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by ck2 on Saturday July 12, 2014 @08:07AM (#8024357)
I really hope this stays on the HN front page for awhile because what a great utility.

I've been using patched copies of coreutils to do the same thing, this is much better.

By the way, if you ever need to quickly spy on rsync you can try this:

       watch lsof -ad3-999 -c rsync
but there is a chance cv will work with rsync too and be more helpful
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by kator on Sunday July 13, 2014 @08:55AM (#8027243)
In the old days I've done this using lsof -p PID and looking at where the files are in relationship to their size. If you have a long running process lsof can be a wonderful tool to figure out how it's doing.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by lamby on Saturday July 12, 2014 @06:14AM (#8024171)
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by mcpherrinm on Saturday July 12, 2014 @04:43AM (#8024042)
Wow, that's such a clever idea! I'm impressed at the simplicity.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by alex_duf on Saturday July 12, 2014 @04:43PM (#8025732)
Sweet ! It's even in the AUR repositories !
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by qwerta on Saturday July 12, 2014 @05:40AM (#8024123)
Very nice idea!
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by TobbenTM on Saturday July 12, 2014 @04:58AM (#8024075)
Ehm, etc is a directory, not a program?

(Sorry, really bad joke...)

Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by jackmaney on Saturday July 12, 2014 @08:41PM (#8026230)
A completely unrelated question: in the terminal screenshots, what is being used for PS1? I love that display of the CWD and git repo on the command line.
Re:Show HN: Linux tool to show progress for cp, rm, dd, etc. by madeofpalk on Saturday July 12, 2014 @08:48PM (#8026244)
It's called Powerline, and it has bindings and configs for nearly every shell, editor, and everything in between including tmux.

http://powerline.readthedocs.org/en/latest/overview.html