https://github.com/qianlnk/pgbar
shell 版本
a=’#’;for i in seq 1 100
;do a=$a#;echo -en ‘[‘$a ‘]%\r’;sleep 0.1;done
golang版本
package main
import (
“fmt”
“os”
“os/exec”
“time”
)
func main() {
stop := false
go func() {
//exec.Command("whoami").Run()
//cmd := exec.Command("/bin/sh", "-c", `/sbin/ifconfig en0 | grep -E 'inet ' | awk '{print $2}'`)
//cmd.Start()
//cmd.Stdout = os.Stdout
//cmd.Run()
for !stop {
cmd := exec.Command("bash", "-c",
"a='#';for i in `seq 1 100`;do a=$a#;echo -en '['$a ']%\r';sleep 0.1;done")
cmd.Stdout = os.Stdout
cmd.Run()
}
}()
go func() {
time.Sleep(1000000)
fmt.Println("go routine")
}()
fmt.Println("main")
time.Sleep(1000000)
stop = true
fmt.Println("done") }
#!/bin/sh
b=’’
for ((i=0;$i<=100;i+=2))
do
printf “progress:[%-50s]%d%%\r” $b $i
sleep 0.1
b=#$b
done
echo
function Proceess(){
spa=’’
i=0
while [ $i -le 100 ]
do
printf “[%-50s] %d%% \r” “$spa” “$i”;
sleep 0.5
((i=i+2))
spa+=’#’
done
echo
}
Proceess
https://blog.51cto.com/shunzi115/2430946
https://blog.csdn.net/zhuxinquan61/article/details/89716301
https://studygolang.com/articles/30029