使用 Linux Shell 实现进度条

7/18/2020 Linux

# 代码

function process(){
    spa=''
    i=0
    while [ $i -le 100 ]
    do
        printf "[%-50s] %d%% \r" "$spa" "$i";
        sleep 0.5
        ((i=i+2))
        spa+='#'
    done
    echo
}

process
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Last Updated: 6/2/2023, 7:17:11 AM