I need to be able to determine the size of a block special file.
For example, given /dev/sda
, I need a command that will provide the size of the device. (By size I mean capacity, since this is a storage device.)
Rationale:
I can store information in the device with:
echo "12345" >/dev/sda # needs to be run as root
(Don't run that command by the way... unless you don't care about your data.)
However, I need to know how much data I can store on the device and I don't know how to do that.
/proc/partitions
, yes. Elsewhere, it depends. – Gilles 'SO- stop being evil' Oct 04 '19 at 23:07