分页: 1 / 1

两个无聊的脚本

发表于 : 2008-11-19 11:58
roylez
网上看来的,挺有意思的。

clock.sh

代码: 全选

#!/bin/bash
# clock.sh

# the script is executed inside a while without conditions
while :                                                                                  
do
 # time and date are formatted to show HH:MM:SS YYYY-MM-DD
 cmd=`date +"%H:%M:%S %F"`
 
 # cursor's current position is saved through an escape sequence
 echo -n -e "\033[s"

 # Uncomment the next two lines to clean up the whole first line, although it causes a lot of blinking
 #tput cup 0 0    # positions on row 0 col 0 (left top corner)
 #tput el         # cleans from position to end of line

 # to place the clock on the appropriate column, subtract the length of 'HH:MM:SS YYYY-MM-DD', which is 19,
 # from the total number of columns
 C=$((`tput cols` - 19))
 tput cup 0 $C    # positions cursor at row 0 col $C

 # clock will be shown green inverted
 # setaf 2 = green, smso = inverted
 COLOR=`tput setaf 2; tput smso`

 # back to normal screen colors
 NORMAL=`tput sgr0`
 
 # print the time-date output on the above position
 echo -n $COLOR$cmd$NORMAL
 
 # restore the cursor to whatever was its previous position
 echo -n -e "\033[u"
 
 # script is executed every second
 sleep 1
done
dance.sh

代码: 全选

#! /usr/bin/sh -i
POS=`tput cup 0 0`
clear
while [ 1 ]
do
echo "${POS}"
tput bel
echo " o "
echo "^|\ "
echo " /\ "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo "^|^ "
echo " >\ "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo "v|^ "
echo "/< "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo "v|v "
echo " >\ "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo "|/v "
echo "/< "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo "|X| "
echo " >\ "
echo "${POS}"
tput bel
sleep 1
echo "<o "
echo " \| "
echo "/< "
echo "${POS}"
tput bel
sleep 1
echo "<o> "
echo " | "
echo " >\ "
echo "${POS}"
tput bel
sleep 1
echo " o> "
echo " \ "
echo "/< "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo " x "
echo " >\ "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo "</ "
echo "/< "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo "<|> "
echo " >\ "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo "</> "
echo "/< "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo "<\> "
echo " >\ "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo "<)> "
echo " >> "
echo "${POS}"
tput bel
sleep 1
echo " o "
echo " |\ "
echo " L "
done 

Re: 两个无聊的脚本

发表于 : 2008-11-19 12:08
eexpress
时间的还可以看下。跳舞的算了。

Re: 两个无聊的脚本

发表于 : 2008-11-19 12:19
bones7456
eexpress 写了:时间的还可以看下。跳舞的算了。
赞同一回~

Re: 两个无聊的脚本

发表于 : 2008-11-19 13:40
HuntXu
mark~

Re: 两个无聊的脚本

发表于 : 2008-11-19 20:37
tnfmg
那个dance有创意 :em11

Re: 两个无聊的脚本

发表于 : 2008-11-21 12:28
greco
好玩 :em11 好玩

Re: 两个无聊的脚本

发表于 : 2008-11-22 3:38
formylove2
dance 开始SH路径要改

Re: 两个无聊的脚本

发表于 : 2008-12-04 20:00
syhan
见识了tput了,好强大阿

Re: 两个无聊的脚本

发表于 : 2008-12-05 13:23
titainium
我也回去玩一玩。
我爱跳舞!!!~~~一起来跳舞~~~~~~~ :em05 :em11