Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 壳程杆_Shell_Progress Bar - Fatal编程技术网

Shell 壳程杆

Shell 壳程杆,shell,progress-bar,Shell,Progress Bar,我想要一个进度条,告诉我直到什么时候pkg更新进度这是我的代码,请纠正它,如果你有一个更好的,然后请给它 #!/bin/bash # progress bar function prog() { local w=80 p=$1; shift # create a string of spaces, then change them to dots printf -v dots "%*s" "$(( $p*$w/100 ))" &q

我想要一个进度条,告诉我直到什么时候pkg更新进度这是我的代码,请纠正它,如果你有一个更好的,然后请给它

#!/bin/bash
# progress bar function
prog() {
    local w=80 p=$1;  shift
    # create a string of spaces, then change them to dots
    printf -v dots "%*s" "$(( $p*$w/100 ))" ""; dots=${dots// /.};
    # print those dots on a fixed-width space plus the percentage etc.
    printf "\r\e[K|%-*s| %3d %% %s" "$w" "$dots" "$p" "$*";
}
x=1
# test loop
while [ pkg update -y ]
 do
    prog "$x" still working...
    sleep .1
    ((x++))
done ; echo
看看有什么想法