shell脚本
来源:互联网 发布:众筹行业数据报告 编辑:程序博客网 时间:2024/06/03 13:51
#!/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 ] && [ -flogical ];then
rm logical
mkdir logical
echo "remove file ==>logical"
echo "and make directory logical"
exit 1
elif [ -e logical ] && [ -dlogical ];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 bedetect!"
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 aslog
for i in $log_path #log_path is an stringarray
do
`rm -rf $i`# remove the single log file
result=$? # get the result lastexecution
if [ $result = 0 ];then
echo "$i has removed successful "#$?=0 means rmsuccessfully
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
------------------------------------------------------------------------------
------------------------------------------------------------------------------
历史上的今天
热度
在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:'' } {ifx.visitorName==visitor.userName} {else} {/if}
{/if} {/list} {if x.moveFrom=='wap'} {elseifx.moveFrom=='iphone'} {elseifx.moveFrom=='android'} {elseifx.moveFrom=='mobile'} {/if}${fn(x.visitorNickname,8)|escape}
${a.selfIntro|escape}{ifgreat260}${suplement}{/if}
0 0
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell 脚本
- SHELL 脚本
- shell脚本
- shell脚本
- shell 脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- Apache负载均衡配置文件
- tomcat 7 配置内存大小
- tomcat 管理平台配置文件
- Linux系统启动自动启动tomcat服务…
- Linux下使用Tomcat7搭建高性能Java…
- shell脚本
- Nutch学习笔记
- hadoop学习笔记(笔记比较乱,随性…
- log4j针对某个类输出到一个日志做…
- 软件测试工程师入门之道
- tomcat 启动脚本
- 给xcode设置快捷键
- Linux Shell 脚本编程之函数
- 大数据hadoop学习之---Yarn 体系架…
评论