有时候,如果你在终端上运行以下命令,可能需要一些时间,取决于要修剪的空间大小。
如何为此获取一个进度条。
我的研究结果是:
在某些其他情况下,可以使用进度条。
sudo fstrim -v /
如何为此获取一个进度条。
我的研究结果是:
在某些其他情况下,可以使用进度条。
sudo fstrim -v /
# Function to show progbar while running command in the background
show_progbar() {
# Uses PID of previous command, unless PID is given as 1st parameter
if [[ -z $1 ]]
then
PID=$!
else
PID=$1
fi
ii=0
jj=0
bar="=" # Character to draw
echo -n " [ "
# While the process with PID is running, progbar is drawing
while [[ -d "/proc/$PID" ]]
do
printf "%b" "\b${bar}]"
(( ii++ ))
sleep .1 # Speed of the progress bar
done
(( ii=ii+3 ))
# Erases the progress bar after it is done
while [[ $jj -lt $ii ]]
do
printf "\b"
(( jj++ ))
done
}
sudo fstrim -v / & \
show_progbar