#!/bin/bash ###Use at your own rigk#### ###2018 - All rights Reverse :-) ###### getuser=$( whoami ) OSX_108_below () #Detect USB devices for OSX 10.8.5 or below. Since diskutil does not report if devices is external { drive=1 while [ $drive -le 50 ]; do if [ -e /dev/disk$drive ] then # device=$( diskutil info /dev/disk$drive | grep "Device / Media Name:" | awk '{print $5}') size=$( diskutil info /dev/disk$drive | grep "Total Size:" | awk '{print $4}' ) protocol=$( diskutil info /dev/disk$drive | grep "Protocol:" | awk '{print $2}' ) if [ "$size" == "GB" ] && [ "$protocol" != "SATA" ] then # n_drive=$(($n_drive + 1 )) echo "/dev/disk$drive" >> "$logpath"/disk.txt echo "/dev/disk$drive" >> "$logpath"/info.txt diskutil info /dev/disk$drive | grep "Device / Media Name:" >> "$logpath"/info.txt diskutil info /dev/disk$drive | grep "Total Size:" >> "$logpath"/info.txt diskutil info /dev/disk$drive | grep "Protocol:" >> "$logpath"/info.txt echo "----------" >> $logpath/info.txt fi if [ "$size" == "TB" ] && [ "$protocol" != "SATA" ] then # n_drive=$(($n_drive + 1 )) echo "/dev/disk$drive" >> "$logpath"/disk.txt echo "/dev/disk$drive" >> "$logpath"/info.txt diskutil info /dev/disk$drive | grep "Device / Media Name:" >> "$logpath"/info.txt diskutil info /dev/disk$drive | grep "Total Size:" >> "$logpath"/info.txt diskutil info /dev/disk$drive | grep "Protocol:" >> "$logpath"/info.txt echo "----------" >> "$logpath"/info.txt fi fi drive=$(($drive + 1 )) done } if [ -d /tmp ] then logpath=/tmp else logpath=$getuser fi drive=1 n_drive=0 while [ $drive -le 10 ]; do diskutil eject disk$drive &>/dev/null drive=$(($drive + 1 )) done diskutil list | grep "external" | awk '{print$1}' >> "$logpath"/disk.txt if [ ! -s "$logpath"/disk.txt ] #check if file is empty because 10.8.5 and below don't device is external then OSX_108_below fi while read line do totalsize=$( diskutil list $line | grep "0:" | awk '{print$4}' ) totalsizeemptyname=$( diskutil list $line | grep "0:" | awk '{print$3}' ) if [ "$totalsize" == "TB" ] || [ "$totalsize" == "GB" ] || [ "$totalsizeemptyname" == "GB" ] || [ "$totalsizeemptyname" == "TB" ] then echo $line >> "$logpath"/d.txt n_drive=$(($n_drive + 1 )) fi done < "$logpath"/disk.txt rm "$logpath"/disk.txt &>/dev/null rm -rf "$logpath"/info.txt &>/dev/null while read line do diskutil eraseDisk JHFS+ My_Drive $line done < "$logpath"/d.txt rm -rf "$logpath"/d.txt ##########I’m trying to help 032874-12682@GG##############