双11的时候,@阿里云安全 做了一个小活动,想看看有多少人能在命令行下搞出时钟效果,用现成的程序或自己编程都ok。
前面已经放出了高级开发工具实现的一批(涵盖Linux/Windows平台),这里再放出Shell实现的一批。
作者:@__MartinWu @rustico @OwenChia
方式:tmux下Ctrl b, t
环境:CentOS 7/RHEL 6 /Ubuntu 14下调试通过
效果:
*******************************************************************
作者:@wbingeek @被吊打的redrain @幸福的酸梅汤 @小八没在家 @爱喝白琳的Gina @爱吃青菜的呼呼呼 @大憨0xCD21 @XuYuanzhen
方式:Shell编程
环境:Fedora 20/RHEL 5/Ubuntu 14
效果:
效果:
效果:
效果:
效果:
代码:
tty-clock -c -f " " -C 4
[font=Arial, 'Microsoft YaHei']
代码:
watch -t -n1 "date +%T|figlet -W -f big"
代码:
clear;
while true;
do tput cup 10 10;
echo `date +%T`;
sleep 1;
clear;
done
代码:
#!/bin/bash
tput civis
while [ 1 ]
do
nonth=$(date +%B)
case "$nonth" in
January)
nonth=1
;;
February)
nonth=2
;;
March)
nonth=3
;;
April)
nonth=4
;;
May)
nonth=5
;;
June)
nonth=6
;;
July)
nonth=7
;;
August)
nonth=8
;;
September)
nonth=9
;;
October)
nonth=10
;;
November)
nonth=11
;;
December)
nonth=12
;;
esac
tput clear
tput cup 3 10
echo $(date +%Y)--$nonth--$(date +%d) $(date +%H):$(date +%M):$(date +%S) $(date +%A)
sleep 1
done
代码:
#!/bin/bash
TIME=`date "+%H:%M"`
char="0"
bg="\x1B[0;37;40m"
fg="\x1B[0;37;42m"
HOR=10
VER=9
clock()
{
TIME=`date "+%H:%M"`
}
plot()
{
p="\x1B["$VER";"$HOR"f"
VER=$[ ( $VER + 1 ) ]
}
zero()
{
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
}
one()
{
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
}
two()
{
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg "
plot
printf "$p$fg $bg "
plot
printf "$p$fg $bg "
}
three()
{
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
}
four()
{
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
}
five()
{
plot
printf "$p$fg $bg "
plot
printf "$p$fg $bg "
plot
printf "$p$fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
}
six()
{
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg "
plot
printf "$p$fg $bg "
plot
printf "$p$fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
}
seven()
{
plot
printf "$p$fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg "
plot
printf "$p$fg $bg "
}
eight()
{
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
}
nine()
{
plot
printf "$p$bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$fg $bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg $fg $bg "
}
colon()
{
plot
printf "$p$bg "
plot
printf "$p$bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg "
plot
printf "$p$bg $fg $bg "
plot
printf "$p$bg "
plot
printf "$p$bg "
}
clear
while true
do
clock
for subscript in $( seq 0 1 4)
do
char="${TIME:${subscript}:1}"
HOR=$[ ( 26 + ( $subscript * 6 ) ) ]
VER=9
if [ "$char" == ":" ]
then
colon
fi
if [ "$char" == "0" ]
then
zero
fi
if [ "$char" == "1" ]
then
one
fi
if [ "$char" == "2" ]
then
two
fi
if [ "$char" == "3" ]
then
three
fi
if [ "$char" == "4" ]
then
four
fi
if [ "$char" == "5" ]
then
five
fi
if [ "$char" == "6" ]
then
six
fi
if [ "$char" == "7" ]
then
seven
fi
if [ "$char" == "8" ]
then
eight
fi
if [ "$char" == "9" ]
then
nine
fi
done
sleep 1
done
**********************************************************************
(以上代码和效果已分开摆放,需要测试的同学请勿按顺序对照,以最终效果为准。)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。