Created
June 17, 2015 06:29
-
-
Save leoh0/c08f2b38185e42e6fe3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while true; do | |
disk=$(ls -al /dev/ | awk '/ disk[0-9]$/{print $10}' | grep -Ev "(disk0|disk1)" | head -n1) | |
if [ "x${disk}" = "x" ]; then | |
sleep 2 | |
continue | |
fi | |
diskpath=/dev/${disk} | |
mount | grep ${diskpath} | |
if [ "x$?" = "x1"]; then | |
sleep 1 | |
continue | |
fi | |
diskutil unmountDisk ${diskpath} | |
diskutil zeroDisk ${diskpath} | |
diskutil partitionDisk ${diskpath} 1 MBRFormat FAT32 UNTITLED 100% | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment