How to Erase a Disk from Command Line in Mac OS X

Some Mac users may require the ability to erase a disk or erase a hard drive from the command line on Mac OS, a task which is typically performed through the Disk Utility application from the GUI. The command line approach to disk erasure in macOS is a bit different and it requires precise syntax to insure that you are erasing the proper disk, making this method of erasing any disk only appropriate for advanced Mac users.
This guide will walk through how to erase and format an entire target disk using exclusively the command line on any Mac using macOS or Mac OS X. You can choose any common file system format the disk to after it has been erased, including ExFAT, FAT32, HFS+, or JHFS+.














