Shell 壳程杆
我想要一个进度条,告诉我直到什么时候pkg更新进度这是我的代码,请纠正它,如果你有一个更好的,然后请给它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
#!/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
看看有什么想法