コンソール出力のテクニック

IT

プログレスバー表示などで使えるテクニック

つらつらと膨大なテキストが流れていくのを抑制し、一行の表示を更新していく。

改行せず、その行の先頭に戻る場合

printf "\r"

さらに、その行の情報をすべてクリアする場合

printf "\r\33[2K"

参考

Erase the current printed console line
How can I erase the current printed console line in C? I am working on a Linux system. For example - printf("hello"); printf("bye"); I want to print bye on t...

VT100 escape codes
IT
広告
一郎くんどっとこむ