#!/bin/bash
#purpose:test for loop to calculate
#date:2015-01-31
#author:lirongqiang
declare -i s #declare s as an integer number
for ((i=i; i<100; i=i+1 ))
do
s=s+i
echo "current i=$i"
done
echo "The result is $s"
------------------------------------------------------------------------------
#!/bin/bash
#purpose:test the for loop as string
#date:2015-01-31
#author:lirongqiang
LIST="Tom cat java python linux ruby perl hadoop"
for i in $LIST
do
echo $i
done
------------------------------------------------------------------------------
#!/bin/bash
#todo: use shell script's parameter code
#date:2015-01-28
#edit: by lrq
echo "this script's name =>$0"
echo "parameters $1 $2 $3 $4 $5 "
------------------------------------------------------------------------------
#!/bin/bash
#TODO:check user is root or not
#DATE:2015-01-30
#AUTHOR:LRQ
if [ $UID -ne 0 ]; then
echo "Non root user. Please run as root."
else
echo "Root uesr"
fi
------------------------------------------------------------------------------
#!/bin/bash
#todo use to calculate some number
#date 2015-01-28
#edit by lrq
declare -i a=2
declare -i b=3
declare -i c=5
declare -i d=13
declare -i e=32
declare -i f=25
declare -i result=$a*$b+$c*$d-$e+$f
echo "expect result is 64"
echo "the final result is $result"
------------------------------------------------------------------------------
#!/bin/bash
#purpose:test file exists if else -f -d -e and so on
#date:2015-01-31
#author:lirongqiang
if [ ! -e logical ];then
touch logical
echo "just make a file logical"
exit 1
elif [ -e logical ] && [ -f logical ];then
rm logical
mkdir logical
echo "remove file ==>logical"
echo "and make directory logical"
exit 1
elif [ -e logical ] && [ -d logical ];then
rm -rf logical
echo "remove directory recursive==>logical "
exit 1
else
echo "Does here have anything"
fi
------------------------------------------------------------------------------
#!/bin/bash
#purpose:check the port is usable
#date:2015-01-31
#author:lirongqiang
#1.print the program's work in your screen
echo "now,the service of your linux system will be detect!"
echo "then www,tft,ssh and sendmail+pop3 will be detect"
echo " "
#2. www
echo "www is running "
echo "www is NOT running "
#3. ftp
echo "FTP is not running"
#4 ssh
echo "ssh is out of service"
#5. sendmail+pop3
echo " receive mail has some problem "
echo " send mail has some problem "
echo "total mail is out of service "
------------------------------------------------------------------------------
#!/bin/bash
#todo show what you have input in the console
#date 2015-01-28
#edit by lrq
echo "please input your name:"
read name
echo "THIS IS YOU INPUT DATA-->$name"
------------------------------------------------------------------------------
#!/bin/bash
#purpose:test case esac
#date:2015-01-31
#author:lirongqiang
#1 print this program
echo "your choice is one"
;;
echo "your choice is two"
;;
echo "your choice is three"
;;
echo "Usag {one|two|three}"
exit 1
------------------------------------------------------------------------------
#!/bin/bash
#purpose:test find directory
#date:2015-01-31
#author:lirongqiang
log_path=`find /root/* -name "*.log"`#to find all named as log
for i in $log_path
#log_path is an string array
do
`rm -rf $i`# remove the single log file
result=$?
# get the result last execution
if [ $result = 0 ];then
echo "$i has removed successful "#$?=0 means rm successfully
else echo "error"
fi
done
------------------------------------------------------------------------------
#!/bin/bash
#purpose:test the for loop as string
#date:2015-01-31
#author:lirongqiang
LIST="Tom cat java python linux ruby perl hadoop"
for i in $LIST
do
echo $i
done
------------------------------------------------------------------------------
------------------------------------------------------------------------------
<script type="text/javascript" id="wumiiRelatedItems"> </script>
历史上的今天
热度
在LOFTER的更多文章
#!/bin/bash
#purpose:test for loop to calculate
#date:2015-01-31
#author:lirongqiang
declare -i s #declare s as an integer number
for ((i=i; i<100; i=i+1 ))
do
\ts=s+i
\techo "current i=$i"
done
echo "The result is $s"
', blogTag:'', blogUrl:'blog/static/21727620920151103945369', isPublished:1, istop:false, type:0, modifyTime:1422767402451, publishTime:1422767402420, permalink:'blog/static/21727620920151103945369', commentCount:0, mainCommentCount:0, recommendCount:0, bsrk:-100, publisherId:0, recomBlogHome:false, currentRecomBlog:false, attachmentsFileIds:[], vote:{}, groupInfo:{}, friendstatus:'none', followstatus:'unFollow', pubSucc:'', visitorProvince:'', visitorCity:'', visitorNewUser:false, postAddInfo:{}, mset:'000', mcon:'', srk:-100, remindgoodnightblog:false, isBlackVisitor:false, isShowYodaoAd:false, hostIntro:'JAVA软件工程师,有扎实的Java基础,熟悉JavaEE技术,对框架的底层原理熟悉,学习能力强。', hmcon:'0', selfRecomBlogCount:'0', lofter_single:'' }
{if x.visitorName==visitor.userName}
{else}
{/if}
{/if} {/list}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
{/if}
${fn(x.visitorNickname,8)|escape}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{/if}
评论