bash
echo -ne "\033[?25l"for i in {1..1000};doecho -ne "\033[K completed $(( $i * 100 / 1000 ))%\r"sleep 0.01doneechoecho all completed!echo -ne "\033[?25h"

PS:
- -n do not output the trailing newline
- -e enable interpretation of backslash escapes
\r carriage return
\033[?25l 关闭光标
- \033[?25h 开启光标
- \033[K 清除光标到行尾的内容
python
import sysimport timefor i in range(1, 1001):sys.stdout.write('\033[K[{0}%] completed\r'.format(i * 100 / 1000))sys.stdout.flush()time.sleep(0.01)print 'all completed!'

another example
import sysimport timeori_line = '=' * 50for i in range(1, 1001):percent = i * 100 / 1000line = '\033[1;32m{}\033[0m{}'.format('>'*(percent/2), ori_line[percent/2:])sys.stdout.write('\033[K[{0:50}] \033[36m{1}%\033[0m\r'.format(line, percent))sys.stdout.flush()time.sleep(0.01)print 'all completed!'
python logging
...format = '\x1b[80D\x1b[1A\x1b[K[%(asctime)s \033[36m%(funcName)s\033[0m %(levelname)s] %(message)s'...
