To install Blockdev in OSX

homebrewinstall

I did not find the command in Brew of Yosemite 10.10.3.
I am reading the command developed from here:

pv -s $(blockdev –getsize64 /Users/masi/Dropbox/1/r3.raw)

I think blockdev is Linux specific command at the moment and not existing directly in OSX.

How can you install Blockdev in OSX?

Best Answer

If you want to get the size of a mounted block device (which is what blockdev -getsize64 does), you can use the following:

diskutil information <device> | grep "Total Size" | sed -e 's/[^(]*(([^Bytes)]*\).*/\1/'

If you want to do the same for a file, you can use the following (amongst many others):

stat -f '%z' <filename>