12
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

Shellの出力でカーソルを移動させる

文字を1文字削除

$ echo "Hello World\b\b\b\b\bWorld"
Hello World

カーソルを左に移動

$ echo "Hello World$(tput cub 5)World"
Hello World

カーソルを上に移動

$ echo "\n$(tput cuu1)Hello World"
Hello World

$(tput cuu1)の代わりに\033[Aでもよい

カーソルを右に移動

$ echo "Hello \n$(tput cuu1)$(tput cuf 6)World"
Hello World

$(tput cuf1)の代わりに\033[Cでもよい

現在の行を削除

$ echo "Hello \n$(tput cuu1)$(tput dl1)Hello World"
Hello World

$(tput dl1)の代わりに\033[Mでもよい

参考

http://wiki.bash-hackers.org/scripting/terminalcodes
http://linuxcommand.org/lc3_adv_tput.php

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
12
Help us understand the problem. What are the problem?