安装脚本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安装脚本学习的更多相关文章

  1. linux命令行与shell脚本编程 -----15控制脚本

    常见的Linux系统信号 信号 值 描述 1 SIGHUP 挂起进程 2 SIGINT 终止进程 3 SIGQUIT 停止进程 9 SIGKILL 无条件终止进程 15 SIGTERM 可能的话终止进 ...

  2. linux shell语言编程规范安全篇之通用原则【转】

    shell语言编程规范安全篇是针对bash语言编程中的数据校验.加密与解密.脚本执行.目录&文件操作等方面,描述可能导致安全漏洞或风险的常见编码错误.该规范基于业界最佳实践,并总结了公司内部的 ...

  3. Linux Shell 高级编程技巧3----运行级别脚本介绍

    3.运行级别脚本介绍    3.1.运行级别        运行级别介绍:            0    关机            1    单用户模式            2    多用户模式 ...

  4. Linux Shell 高级编程技巧4----几个常用的shell脚本例子

    4.几个常用的shell脚本例子    4.0.在写脚本(同样适用在编程的时候),最好写好完善的注释    4.1.kill_processes.sh(一个杀死进程的脚本) #!/bin/bash c ...

  5. 数据仓库005 - 复习Linux shell命令 - crontab调度 sh脚本 后台执行 软连接

    一.crontab调度 对于linux 自带crontab而言,      xxx.sh的一般编写格式以#!/bin/bash 解释器开头,可在脚本中加入: date 但是,shell脚本执行 需要 ...

  6. [转]linux shell 获取当前正在执行脚本的绝对路径

    原文链接:http://sexywp.com/bash-how-to-get-the-basepath-of-current-running-script.htm 常见的一种误区,是使用 pwd 命令 ...

  7. linux shell:nginx日志切割脚本

    需求原因:nginx不具备日志切割功能,日志量较大,方便分析. 实现目的:完成nginx日志切割,并根据时间命名   简要命令: mv /usr/local/tengine/logs/access.l ...

  8. Oracle安装部署之linux OS install oracle database安装脚本

    #!/bin/bash#Purpose:Create and config oracle install.#Usage:Log on as the superuser('root') #1.creat ...

  9. linux shell每天一阅 -- 安装nginx以及apache

    当然这个博客原代码是转载大神的... 自动安装Nginx脚本,采用case方式,选择方式,也可以根据实际需求改成自己想要的脚本mynginx.sh #!/bin/sh ###nginx install ...

随机推荐

  1. BZOJ 1934--善意的投票(最小割)

    1934: [Shoi2007]Vote 善意的投票 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 2354  Solved: 1471[Submit][ ...

  2. 【vue】——CDN或全局引入CSS、JS。

    在入口文件index.html中添加 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...

  3. 爬虫7:selenium

    1. 一个简单的使用例子 from selenium import webdriver from selenium.webdriver.common.by import By from seleniu ...

  4. centos和ubuntu配置路由的三种方式

    本篇总结三种修改路由的方式:route, ip route, 以及通过修改文件来配置路由,前2种命令行形式适用于ubuntu和centos,重启失效,最后一种永久有效.     一. route命令 ...

  5. Nginx采用yum安装-Carr

    (1)使用yum安装nginx需要包括Nginx的库,安装Nginx的库 #rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx- ...

  6. 安装php7

    ./configure  --prefix=/usr/local/php7.1.5 --with-curl --with-iconv-dir  --with-mysqli --with-openssl ...

  7. 2016级算法第六次上机-D.AlvinZH的学霸养成记V

    1081 AlvinZH的学霸养成记V 思路 中等题,计算几何. 这是一个排序问题,按极角排序.可以转化为叉积的应用,对于点A和B,通过叉积可以判断角度大小,共线时再判断距离. 叉积的应用.OA × ...

  8. 把一个集合自定转成json字符串

    List<CityData> listData =new List<CityData>(); //把一个集合自定转成json字符串. foreach (var city in ...

  9. jinja url_for js 参数

    在JavaScript中,也就是客户端,向flask路由服务器端使用post请求并在url_for中传递参数,服务器端获取不到该参数, Jinja不能使用Javascript变量,如下所示: var ...

  10. P2486 [SDOI2011]染色(树剖)区间覆盖+区间的连续段

    https://www.luogu.org/problemnew/show/P2486 值的一看https://www.cnblogs.com/Tony-Double-Sky/p/9283262.ht ...