title: Mac OS X Bash get /dev/diskNsM size
body: <p>How could I get device size in <strong>bytes</strong>?</p>
  
  <p>In Mac OS X 10.6 I am using this:</p>
  
  <pre><code>$ diskutil information /dev/disk0s2
     Device Identifier:        disk0s2
     Device Node:              /dev/disk0s2
     Part Of Whole:            disk0
     Device / Media Name:      macOSX106
  
     Volume Name:              macOSX106
     Escaped with Unicode:     macOSX106
  
     Mounted:                  Yes
     Mount Point:              /
     Escaped with Unicode:     /
  
     File System:              Journaled HFS+
     Type:                     hfs
     Name:                     Mac OS Extended (Journaled)
     Journal:                  Journal size 8192 KB at offset 0x12d000
     Owners:                   Enabled
  
     Partition Type:           Apple_HFS
     Bootable:                 Is bootable
     Media Type:               Generic
     Protocol:                 SATA
     SMART Status:             Verified
     Volume UUID:              E2D5E93F-2CCC-3506-8075-79FD232DC63C
  
     Total Size:               40.0 GB (40013180928 Bytes) (exactly 78150744 512-Byte-Blocks)
     Volume Free Space:        4.4 GB (4424929280 Bytes) (exactly 8642440 512-Byte-Blocks)
  
     Read-Only Media:          No
     Read-Only Volume:         No
     Ejectable:                No
  
     Whole:                    No
     Internal:                 Yes
  </code></pre>
  
  <p>and it's work fine. But in Mac OS X 10.4 the output will be</p>
  
  <pre><code>$ diskutil info disk0s2
     Device Node:        /dev/disk1s2
     Device Identifier:  disk1s2
     Mount Point:        
     Volume Name:        
  
     Partition Type:     Apple_HFS
     Bootable:           Not bootable
     Media Type:         Generic
     Protocol:           SATA
     SMART Status:       Not Supported
  
     Total Size:         500.0 MB
     Free Space:         0.0 B
  
     Read Only:          No
     Ejectable:          Yes
  </code></pre>
  
  <p>and there is no something like (40013180928 Bytes) (exactly 78150744 512-Byte-Blocks)</p>
  
  <p>My bash script parses the diskutil output, extract Total Size in bytes and grab last 10 Mb of the disk with the <code>dd</code> command, so in 10.4 it doesn't work...</p>
  
  <p>How could I get the size in bytes another way?</p>