Linux操作系统的Shell编程脚本欣赏
- #!/bin/bash
-
- #trim the charactor in head and tail
-
- L_trim()
- tmp=${rand_time:0:1}
-
- while [ $tmp = 0 ]
- do
- rand_time=${rand_time:1}
-
- tmp=${rand_time:0:1}
- done
- }
-
- R_trim()
- {
- Len=${#rand_time}
- let "sLen =Len -1"
- tmp=${rand_time:sLen:1}
- while [ $tmp = 0 ]
- do
- rand_time=${rand_time:0:$sLen}
- Len=${#rand_time}
- let "sLen =Len -1"
- tmp=${rand_time:sLen:1}
- done
- }
- #get current time as random
- rand_time=`date '+%N'`
- #trim the "0" from the var
- #rand_time=${rand_time:0:6}
- L_trim
- R_trim
- #get filecount of $1
- fcount=`ls $1 | wc -l`
- echo "fcount $fcount"
- #get a random number between 1 and fcount
- rand_num=$(($rand_time % $fcount ))
- echo $rand_num
-
- tmp=1
- for file in $1/*.jpg
- do
- if [ $tmp -lt $rand_num ]
- then
- let "tmp=tmp+1"
- continue
- fi
- #qiv -Tx $HOME/.wallpaper.jpg
- echo "file:$file"
- break;
- done
作者: coolentboy 发布时间: 2006-10-16
作者: 邱建元 发布时间: 2006-10-16
作者: chameleon 发布时间: 2006-10-16
作者: spark1313 发布时间: 2006-10-16
作者: spark1313 发布时间: 2006-10-19
作者: michrykitty 发布时间: 2006-10-19
作者: pomerl 发布时间: 2007-12-25
作者: 逍遥の石头 发布时间: 2010-02-28
作者: liu351128 发布时间: 2010-03-04
作者: xtygaht 发布时间: 2010-03-04
作者: 坏boy 发布时间: 2010-03-04
作者: jan729 发布时间: 2010-04-17
作者: axbyc123 发布时间: 2010-04-18
作者: axbyc123 发布时间: 2010-04-19
作者: axbyc123 发布时间: 2010-04-19
作者: 飞虎小白龙 发布时间: 2010-04-19
作者: 飞虎小白龙 发布时间: 2010-05-21
作者: hurricane668 发布时间: 2010-05-24
作者: daidengke 发布时间: 2010-05-24
作者: lp518 发布时间: 2010-05-30
作者: 发布时间: 2010-12-05