我们想通过在 AIX 7 上使用 shell 脚本来自动化磁盘清理过程。我们需要编写一个 shell 脚本来根据磁盘百分比清理磁盘
df -Pg 的样本输出
user:host:/:>df -Pg
Filesystem GB blocks Used Available Capacity Mounted on
/dev/hd4 5.00 0.05 4.95 2% /
/dev/hd2 6.00 3.63 2.37 61% /usr
/dev/work1lv 1074.50 377.46 697.04 36% /work1
... some lines are ommitted and it continues
我们只想使用 cut 命令检查容量百分比 我们不能只列出作为参数给 cut 命令 -f 的第 5 列。如果我们成功正确显示,我们将继续使用 shell 脚本清理部分。
df -Pg | cut -f5 -d' '
上面命令的输出不是我们所期望的。