jeudi 29 octobre 2015

Break for loop if variable is false

Trying to break a for loop if the variable $DEVP doesn't exist.

nme=(Y6T1 Y6-T1 Y6.T1 Yr6T1 Yr6-T1 Yr6.T1 Yr6Term1)
DEVP=(/dev/disk2 /dev/disk3 /dev/disk4 /dev/disk5 /dev/disk6 /dev/disk7 /dev/disk8)

for ((i = 0; i < 7; i++)) ; do 
    if [ ${nme[i]} ${DEVP[i]} = 0 ] ; then
        diskutil eraseDisk FAT32 ${nme[i]} ${DEVP[i]}
    else
        echo “Formatted USBs” ; break
    fi
done

Aucun commentaire:

Enregistrer un commentaire