本文共 1404 字,大约阅读时间需要 4 分钟。
#!/bin/bashfdisk -l | grep -o "/dev/[a-z].*d[a-z]" | uniq read -p " qing xuanze yao geshihuade disk q is exit : " diskif [ $disk == q ]then echo "exit#######################33" exit 1fiuntil fdisk -l | grep -o "/dev/[a-z].*d[a-z]" | uniq | grep -o $disk do echo "error..............exit###################" exit 2done a=`fdisk -l | grep -o "/dev/[a-z].*d[a-z]" | uniq | grep -o $disk | awk -F "/" '{print $3}'`b=`fdisk -l | grep -o "/dev/[a-z].*d[a-z]" | uniq | awk -F "/" '{print $3}' > /tmp/xx`for n in `cat /tmp/xx ` do if [ "$n" == "$a" ] then > read -p "niquedinggeshihua $disk y/n : " yn if [ $yn == n -o $yn != y ] then echo "exit........" exit 3 else fdisk -l | grep -oE "$disk[1-9].*" |awk '{print $1}' | xargs umount > /dev/null 2>&1 dd if=/dev/zero of=$disk count=512 bs=1 > /dev/null 2>&1 echo -e "n\np\n1\n\n+10M\nw\n" | fdisk $disk > /dev/null 2>&1 echo -e "n\np\n2\n\n+10M\nw\n" | fdisk $disk > /dev/null 2>&1 echo -e "n\np\n3\n\n+10M\nw\n" | fdisk $disk > /dev/null 2>&1 printf "%-20s %-12s %-8s %-7s %-2s %-1s \n" Boot Start End Blocks Id System fdisk -l | grep -oE "$disk[1-9].*" exit 0 fi fidone
转载于:https://blog.51cto.com/hequan/1834578