12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2014-06-15

#文字を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

12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?