撰于 阅读 24

命令行单行刷新, 实现进度条效果

在一行的开头加上 \r

#!/bin/bash
for i in {1..100}
do
    printf "\r running: %d%% !!!" $i
    sleep 1
done

# print a new line