Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all,
I find the Watch command very useful for monitoring the progress of large image files being copied over. However, the default output is in bytes and I would prefer (*much* prefer) to have it divided by 10^9 so I get to see gigabytes instead. What is the correct switch to use for this, please?
Thanks!
The watch command doesn't output bytes or gigabytes. In your case, the output probably comes from the command that it watches, such as dd. To help you, we would need to know how you use watch.
Commands that deal with bytes often have a -h/--human-readable option.
rsync (which is commonly used to copy large files) has this option, and also has -v/--verbose and -P/--progress options that may avoid the need for watch.
(If you're on the receiving end and using watch with ls, you will find that command also has a -h/--human-readable option.)
I'm using it for monitoring the progress of dd as it images a partition:
Code:
watch /mnt/sdb1/imagefilename.img
Even though the partition is 'only' 149Gb in size it's *really* hard to tell whether it's at 14.9Gb or 149Gb. I'd assumed like df for 'disk free' it would have the human-friendly -h switch but it seems it doesn't.
Your watch example makes no sense. For one, it's incomplete. It is missing 'dd' if you meant to include that and either an input option or an output option, depending on what you want to do with that image. Two, there is nothing to watch in a dd command if its command does not include the status option. 'df -h' is a better use of the watch command. dd not saying anything all the way to the prompt is a good thing but that's unnerving for a lot of people, lol.
Depending on its version, dd has progress status. Here's an example with the status option.
I'm using it for monitoring the progress of dd as it images a partition:
Code:
watch /mnt/sdb1/imagefilename.img
Even though the partition is 'only' 149Gb in size it's *really* hard to tell whether it's at 14.9Gb or 149Gb. I'd assumed like df for 'disk free' it would have the human-friendly -h switch but it seems it doesn't.
You probably mean something like this:
Code:
watch -n 1 -- ls -lh /mnt/sdb1/imagefilename.img
That will review the size of imagefilename.img every second.
Okay, thanks guys. Seems I should forget about Watch and use status=progress with dd instead. But.... will the same problem arise again or will this genuinely provide a more readable output?
I should add there was no such 'progress' option with dd in the Linux Commands Bible I have (dated 2008) so it seems it's something that's been built into dd as an update at some time later.
The 'status=progress' option was added "recently", yes. I first learned about it here at linuxquestions.org.
I see from the posts after mine that you probably meant to have 'ls' instead of 'dd' in your 'watch' example. Now that makes more sense. 'watch' doesn't covert whatever command you've given it to something else. It just execute your commands and display the result at interval. That's all it does. So if you want to see a command printout in a human-readable form, you need to hit the man pages (or search online) of whatever command you're giving 'watch' to do and find that switch. It's often the '-h' switch but not always.
'watch' is a useful tool to have. Keep at it til you've figured it out.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.