Created
December 14, 2014 08:36
-
-
Save komasaru/ef25eb2a1d6fa57146f6 to your computer and use it in GitHub Desktop.
Bash script to control cursor position.(Ex.1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 1. 指定文字数左へ移動後に echo | |
# ( 最後の echo 以外は改行しない ) | |
# | |
echo -n `date +"%Y-%m-%d %H:%M:%S"` | |
for i in {0..4}; | |
do | |
sleep 1 | |
tput cub 19 | |
echo -n `date +"%Y-%m-%d %H:%M:%S"` | |
done; | |
tput cub 19 | |
echo `date +"%Y-%m-%d %H:%M:%S"` | |
echo "-------------------" | |
# 2. 指定行数上へ移動後に echo | |
# ( 毎回改行 ) | |
# | |
echo `date +"%Y-%m-%d %H:%M:%S"` | |
for i in {0..4}; | |
do | |
sleep 1 | |
tput cuu 1 | |
echo `date +"%Y-%m-%d %H:%M:%S"` | |
done; | |
tput cuu 1 | |
echo `date +"%Y-%m-%d %H:%M:%S"` | |
echo "-------------------" | |
# 3. 行の先頭へ復帰(CR(\r))後 printf | |
# ( 最後の echo 以外は改行しない ) | |
# | |
printf "%10s %8s" `date +"%Y-%m-%d %H:%M:%S"` | |
for i in {0..4}; | |
do | |
sleep 1 | |
printf "\r%10s %8s" `date +"%Y-%m-%d %H:%M:%S"` | |
done; | |
printf "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment