gpt4 book ai didi

linux - DD 脚本和操作数预期错误

转载 作者:太空宇宙 更新时间:2023-11-04 11:47:04 25 4
gpt4 key购买 nike

<分区>

我正在尝试实现一行代码,以防止用户删除主机闪存驱动器(实际上小于 110 GB)

#!/bin/bash
RED='\033[0;31m'
NC='\033[0m'
END='\033[0m'
FLASH='\e[5m'
dt=`date '+%m/%d/%Y_%H:%M:%S'`
echo -e "STILL BE CAREFUL!! SIZE CHECK IS STILL NON-FUNCTIONAL"
echo "Inspect the drive for multiple boot/storage/recovery partitions. Check out the README.odt for reference photos."
sudo gnome-disks
echo "Showing list of drives: "
sudo fdisk -l | grep -i "Disk /"
echo "What drive are you attempting to wipe? Do not include /dev/"
read drive
size= sudo fdisk -l | grep -i "Disk /dev/$drive" | awk -F" " {'print $3'}
printf %.0f $size
if (( $size <= 110 ))
then
echo -e "$size"
echo -e "${RED}${FLASH}Error: You are trying to wipe a disk that is less than 110 GB. There's a high chance this is the host flashdrive. If you are sure this is the correct drive use\n ${END}${RED}sudo dd if=/dev/urandom of=/dev/<drive here> bs=1M status=progress${NC}"
else
echo -e "${RED}Now wiping drive /dev/$drive!${END}"
sudo dd if=/dev/urandom of=/dev/$drive bs=1M status=progress
echo -e "${RED}${FLASH}Wiping has completed at $dt !!!${END}"
echo "Drive in question should only have one main partition. See README.odt for reference."
sudo gnome-disks

fi
echo "Please enter Ctrl + C to exit!"
sleep 10000

如果我尝试删除 8.7 GB 的 sda,我希望它会抛出我创建的错误。相反,它表示预期的操作数错误,然后继续删除测试闪存驱动器。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com