Skip to content

Instantly share code, notes, and snippets.

@leoh0
Created June 17, 2015 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoh0/c08f2b38185e42e6fe3e to your computer and use it in GitHub Desktop.
Save leoh0/c08f2b38185e42e6fe3e to your computer and use it in GitHub Desktop.
#!/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