[linux] shell脚本编程-xunsearch安装脚本学习
安装脚本setup.sh
#!/bin/sh
# FULL fast install/upgrade script
# See help message via `--help'
# $Id$ # self check
if ! test -d ./packages ; then
echo "ERROR: you should run the script under its directory"
echo "错误:您只能在脚本所在目录运行它"
exit -
fi # get default prefix
if test -f $HOME/.xs_installed ; then
def_prefix=`cat $HOME/.xs_installed`
elif test "$HOME" = "/" || test "$HOME" = "/root" ; then
def_prefix=/usr/local/xunsearch
else
def_prefix=$HOME/xunsearch
fi
if ! test -d ./packages ; then
1.shell脚本编程中的if判断配合test命令,判断目录是否存在
2.if判断格式如,写成一行 ,if test 条件;then 动作;else 动作;fi
3.判断条件相等用-eq 或者 =,不相等 -ne
4.if test -d $HOME ;then echo "$HOME is dir";else echo "$HOME is not dir";fi
$HOME
1.家目录的环境变量
i=
while [ $i -lt $# ] ; do
i=`expr $i + `
eval arg=\$$i
opt=`echo $arg | cut -d= -f1`
val=`echo $arg | cut -d= -f2`
case $opt in
"--prefix")
set_prefix="$val"
;;
"--no-clean")
set_no_clean=yes
;;
# just for back compatibility
"--clean")
do_clean
exit
;;
"--force")
if test "$val" != "no" ; then
set_force=yes
fi
;;
"--enable-debug"|"--enable-memory-cache")
xs_add_option="$xs_add_option $arg"
;;
"--jobs")
mk_add_option="$mk_add_option -j$val"
;;
"--help")
show_usage
exit
;;
*)
echo "ERROR: unknown option '$arg'" >&
echo "" >&
show_usage
exit -
;;
esac
done
while [ $i -lt $# ] ; do
1.while循环,当$i小与$#时,执行
2.while循环举例,注意空格
b=0;while [ $b -lt 5 ]; do b=`expr $b + 1`;echo $b; done
i=0
while [ $i -lt $# ] ; do
i=`expr $i + 1`
1.while循环 i=0;while [ $i -lt 5 ];do i=`expr $i + 1 `;echo $i;done
2.特殊变量$#是传递的参数个数
3.命令替换 ``
4.数学表达式工具 expr, echo `expr 1 + 1`
eval arg=\$$i
1.eval 把字符串变成变量
2.特殊变量 $1 $2,传递的参数
while test -z ""; do
1.test -z 判断字符串空,则为真 if test -z "";then echo 1;fi
2.test -n 判断字符串存在,则为真 if test -n "sss";then echo 1;fi
[linux] shell脚本编程-xunsearch安装脚本学习的更多相关文章
- linux命令行与shell脚本编程 -----15控制脚本
常见的Linux系统信号 信号 值 描述 1 SIGHUP 挂起进程 2 SIGINT 终止进程 3 SIGQUIT 停止进程 9 SIGKILL 无条件终止进程 15 SIGTERM 可能的话终止进 ...
- linux shell语言编程规范安全篇之通用原则【转】
shell语言编程规范安全篇是针对bash语言编程中的数据校验.加密与解密.脚本执行.目录&文件操作等方面,描述可能导致安全漏洞或风险的常见编码错误.该规范基于业界最佳实践,并总结了公司内部的 ...
- Linux Shell 高级编程技巧3----运行级别脚本介绍
3.运行级别脚本介绍 3.1.运行级别 运行级别介绍: 0 关机 1 单用户模式 2 多用户模式 ...
- Linux Shell 高级编程技巧4----几个常用的shell脚本例子
4.几个常用的shell脚本例子 4.0.在写脚本(同样适用在编程的时候),最好写好完善的注释 4.1.kill_processes.sh(一个杀死进程的脚本) #!/bin/bash c ...
- 数据仓库005 - 复习Linux shell命令 - crontab调度 sh脚本 后台执行 软连接
一.crontab调度 对于linux 自带crontab而言, xxx.sh的一般编写格式以#!/bin/bash 解释器开头,可在脚本中加入: date 但是,shell脚本执行 需要 ...
- [转]linux shell 获取当前正在执行脚本的绝对路径
原文链接:http://sexywp.com/bash-how-to-get-the-basepath-of-current-running-script.htm 常见的一种误区,是使用 pwd 命令 ...
- linux shell:nginx日志切割脚本
需求原因:nginx不具备日志切割功能,日志量较大,方便分析. 实现目的:完成nginx日志切割,并根据时间命名 简要命令: mv /usr/local/tengine/logs/access.l ...
- Oracle安装部署之linux OS install oracle database安装脚本
#!/bin/bash#Purpose:Create and config oracle install.#Usage:Log on as the superuser('root') #1.creat ...
- linux shell每天一阅 -- 安装nginx以及apache
当然这个博客原代码是转载大神的... 自动安装Nginx脚本,采用case方式,选择方式,也可以根据实际需求改成自己想要的脚本mynginx.sh #!/bin/sh ###nginx install ...
随机推荐
- Get 和 Post 方法的选择和URL的设计
原文链接:http://yifei.me/note/540 HTTP 中常用的方法有 GET/POST/PUT/DELETE 等,在设计API或者表单的时候我们需要选择合适的方法.一般有两种方案: 只 ...
- 部署LVS-DR群集
一.LVS-DR原理剖析 (一)LVS-DR数据包流向分析 1.Client向目标VIP发出请求,Director(负载均衡器)接收.此时IP包头及数据帧头信息为: 2.Director根据负载均衡算 ...
- iOS学习笔记(4)——显示单组件选取器
1. 创建工程 创建新工程,create a new Xcode project 创建single view application 创建名为PickerViewTest的工程 2. 创建xib文件 ...
- Xcode 工程文件“.xcodeproj”文件夹解析
项目.xcodeproj 文件夹底下一般有4个文件: project.pbxproj 文件 xcuserdata 文件夹 xcshareddata 文件夹 project.xcworkspace 文件 ...
- 【JavaScript】类继承(对象冒充)和原型继承__深入理解原型和原型链
JavaScript里的继承方式在很多书上分了很多类型和实现方式,大体上就是两种:类继承(对象冒充)和原型继承. 类继承(对象冒充):在函数内部定义自身的属性的方法,子类继承时,用call或apply ...
- Django分页类的封装
Django分页类的封装 Django ORM 封装 之前有提到(Django分页的实现)会多次用到分页,将分页功能封装起来能极大提高效率. 其实不是很难,就是将之前实现的代码全都放到类中,将需要用 ...
- Exponentiation POJ-1001
http://poj.org/problem?id=1001 //10000000 100000 #include<iostream> #include<cstring> us ...
- 关于Vue中main.js,App.vue,index.html之间关系进行总结
在初始化的Vue项目中,我们最先接触到的就是main.js,App.vue,index.html这三个文件,我们从培训视频或者官方文档上可以了解到: index.html---主页,项目入口 App. ...
- [性能测试]:ISO8583报文解析实例
现在我们有ISO8583报文如下(十六进制表示法): 60 00 03 00 00 60 31 00 31 07 30 02 00 30 20 04 C0 20 C0 98 11 00 00 00 0 ...
- [转] 遇见 TiDB - 分布式关系数据库
[From] http://kuaibao.qq.com/s/20180510G0UFL000?refer=cp_1026 最近TiDB掀起了一波分布式数据库的热潮,公司也在着手准备TiDB的落地工作 ...