[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 ...
随机推荐
- java学习笔记—标准连接池的实现(27)
javax.sql.DataSource. Java.sql.* DataSource 接口由驱动程序供应商实现.共有三种类型的实现: 基本实现 - 生成标准的 Connection 对象 – 一个D ...
- C语言 一些算法
1,斐波那契数列 ①递归 时间复杂度O(2^n)#include <stdio.h> int fib(int n){ ||n==) ; ) + fib(n-); } int main(){ ...
- 10分钟教你用Python打造微信天气预报机器人
01 前言 最近武汉的天气越来越恶劣了.动不动就下雨,所以,拥有一款好的天气预报工具,对于我们大学生来说,还真是挺重要的了.好了,自己动手,丰衣足食,我们来用Python打造一个天气预报的微信机器人吧 ...
- P2278 操作系统
P2278 操作系统 题目描述 写一个程序来模拟操作系统的进程调度.假设该系统只有一个CPU,每一个进程的到达时间,执行时间和运行优先级都是已知的.其中运行优先级用自然数表示,数字越大,则优先级越高. ...
- Linux系统NAT模式下设置网络网关
1.配置Vm网络编辑器 2.配置固定IP地址 命令:vi /etc/sysconfig/network-scripts/ifcfg-ens33 #下面内容直接复制进去,如果有重复的可以去除 TYPE= ...
- Windows运行常用命令(win+R)
Windows运行常用命令(win+R) 1.calc: 启动计算器 2.notepad: 打开记事本 3.write: 写字板 4.mspaint: 画图板 5.snippingtool:截图工具, ...
- 往word中插入美观的代码
http://www.planetb.ca/syntax-highlight-word 选择需要的语言,然后Show Highlighted,复制跳转页面显示的代码至word即可
- AES对称加解密
简介设计思想加密模式ECB模式(电子密码本模式:Electronic codebook)CBC模式(密码分组链接:Cipher-block chaining)CFB模式(密文反馈:Cipher fee ...
- Flutter视图基础简介--Widget、Element、RenderObject
前言:Flutter官方文档里的一句话:you build your UI out of widgets(使用Flutter开发UI界面时,都是使用Widget),然而,Widget并不是我们真正看到 ...
- net与树莓派的情缘-安装Redis(四)
在Linux下安装Redis非常简单,具体步骤如下(官网有说明): .下载源码,解压缩后编译源码. $ wget http://download.redis.io/releases/redis-3.0 ...