如何实现命令行进度条?

关键点

  • \r

  • -ne

\r 保证从行开始处开始输出
-ne 不输出换行 \n

demo:

echo -ne '#####                     (33%)\r'
sleep 1
echo -ne '#############             (66%)\r'
sleep 1
echo -ne '#######################   (100%)\r'
echo -ne '\n'

参考

http://stackoverflow.com/ques...

一些 Golang 项目

  • mitchellh/ioprogress: Go (golang) package for progress bars around io.Reader/Writers.

  • cheggaaa/pb: Console progress bar for Golang

  • sethgrid/multibar: Display multiple progress bars in Go (golang).

  • mitchellh/cli: A Go library for implementing command-line interfaces.

你可能感兴趣的:(bash)