fdisk可以划分磁盘分区。下面给出使用Fdisk命令进行磁盘分区的操作步骤: #fdisk /dev/had //使用/dev/had作为默认的分区设备 Command (m for help): m //选择命令选项 Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition’s system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) 用户通过提示键入“m”,可以显示Fdisk命令各个参数的说明。
echo "------------1、准备删除 ~/Library/Developer/Xcode/DerivedData" for file in ~/Library/Developer/Xcode/DerivedData/*;do # 确定是目录 if test -d $file;then echo "删除--->"$file rm -rf $file fi done
echo "------------2、准备删除 /Users/lebbay/DerivedData" for file in /Users/lebbay/DerivedData/*;do # 确定是目录 if test -d $file;then echo "删除--->"$file rm -rf $file fi done
echo "------------3、准备删除 ~/Library/Developer/Xcode/Archives" for file in ~/Library/Developer/Xcode/Archives/*;do # 确定是目录 if test -d $file;then # 不是今天的都删掉 today=$(date "+%Y-%m-%d") if [[ ! $file =~ $today ]];then echo "删除--->"$file rm -rf $file fi fi done
echo "------------4、准备删除 /Users/lebbay/Archives" for file in /Users/lebbay/Archives/*;do # 确定是目录 if test -d $file;then # 不是今天的都删掉 today=$(date "+%Y-%m-%d") if [[ ! $file =~ $today ]];then echo "删除--->"$file rm -rf $file fi fi done
echo "------------5、准备删除 ~/Library/Developer/CoreSimulator/Devices,仅保留 SE 机型"
for file in ~/Library/Developer/CoreSimulator/Devices/*;do # 确定是目录 if test -d $file;then device_plist="${file}/device.plist" device_plist_text=`cat $device_plist` se_line="<string>com.apple.CoreSimulator.SimDeviceType.iPhone-SE" if [[ ! $device_plist_text =~ $se_line ]]; then echo "删除--->"$file rm -rf $file else echo "保留--->"$file fi fi done
echo "------------6、准备删除 ~/Library/Developer/Xcode/iOS\ DeviceSupport,保留自动化测试常用系统" for file in ~/Library/Developer/Xcode/iOS\ DeviceSupport/*;do # 手机系统升级之后就不好使喽。。。 # iPhone 8 序列号:F4GX3EK1JC6F iphone_13_3_1="/13.3.1" # iPhone X 序列号:G0NVPS22JCLF iphone_14_0_1="/14.0.1" if [[ $file =~ $iphone_13_3_1 ]]; then echo "保留--->"$file elif [[ $file =~ $iphone_14_0_1 ]]; then echo "保留--->"$file else echo "删除--->"$file rm -rf $file fi done # 最后查询一下当前硬盘空间 echo "🌛 0、开始清理前硬盘空间" df -lh