【发布时间】:2018-07-27 21:11:31
【问题描述】:
好的,对于新的 High Sierra,我正在尝试编写一个脚本来自动删除占用硬盘空间的本地快照。我知道你可以使用 thinlocalsnapshots / 1000000000 4 进行缩小,但我觉得这只是一个创可贴。
所以我要做的是从以下位置提取日期 2018-02-##-######:
sudo tmutil listlocalsnapshots /
com.apple.TimeMachine.2018-02-15-170531
com.apple.TimeMachine.2018-02-15-181655
com.apple.TimeMachine.2018-02-15-223352
com.apple.TimeMachine.2018-02-16-000403
com.apple.TimeMachine.2018-02-16-013400
com.apple.TimeMachine.2018-02-16-033621
com.apple.TimeMachine.2018-02-16-063811
com.apple.TimeMachine.2018-02-16-080812
com.apple.TimeMachine.2018-02-16-090939
com.apple.TimeMachine.2018-02-16-100459
com.apple.TimeMachine.2018-02-16-110325
com.apple.TimeMachine.2018-02-16-122954
com.apple.TimeMachine.2018-02-16-141223
com.apple.TimeMachine.2018-02-16-151309
com.apple.TimeMachine.2018-02-16-161040
我已经尝试过各种变体
| awk '{print $ } (insert number after $)
随着
| cut -d ' ' -f 10-.
如果您知道我在这里缺少什么,我将不胜感激
编辑:这是摆脱那些讨厌的本地快照的脚本。如果有人有兴趣,再次感谢:
#! /bin/bash
dates=`tmutil listlocalsnapshots / | awk -F "." 'NR++1{print $4}'`
for dates in $dates
do
tmutil deletelocalsnapshots $dates
done
【问题讨论】:
标签: bash macos operating-system