shell脚本
来源:互联网 发布:java管理系统有哪些 编辑:程序博客网 时间:2024/06/08 07:22
1 数组的使用
#!/bin/bash
name="zhangdiqing"
echo ${#name}
echo ${name:1:4}
echo $name $name
name="zhangdiqing"
echo `expr index "$string" is`
array_name=(zhang,wang,li,zhao)
array=(
zhang
wang
li
zhao)
#the index no bondary
array_name[0]=qing
#read the array
echo ${array_name[0]}
#read all
echo ${array_name[@]}
#gain the len
len=${#array_name[@]}
len=${#array_name[*]}
2. 运算符的使用
#!/bin/bash
val=`expr 2 + 2`
echo $val
a=10
b=12
if [ $a -eq $b ]
then
echo "a==b"
fi
if [ $a -ne $b ]
then
echo "a!=b"
fi
if[ $a -gt $b ]
# a>b
then
echo "a>b"
fi
if [ $a -lt $b ]
#a<b
then
echo "a<b"
fi
if [ $a -ge $b ]
# a>=b
then
echo "a>=b"
fi
if [ $a -le $b ] #a<=b
then
echo "a<=b"
fi
if [ ! false ]
then
echo "!false"
fi
if [ false -o true ] # bool or
echo "false -o true"
fi
# [ false -a true ] #bool and
#
#
#
# [0&&7] #logical and
# [0||1] #logical or
val=`expr 2 + 2`
echo $val
a=10
b=12
if [ $a -eq $b ]
then
echo "a==b"
fi
if [ $a -ne $b ]
then
echo "a!=b"
fi
if[ $a -gt $b ]
# a>b
then
echo "a>b"
fi
if [ $a -lt $b ]
#a<b
then
echo "a<b"
fi
if [ $a -ge $b ]
# a>=b
then
echo "a>=b"
fi
if [ $a -le $b ] #a<=b
then
echo "a<=b"
fi
if [ ! false ]
then
echo "!false"
fi
if [ false -o true ] # bool or
echo "false -o true"
fi
# [ false -a true ] #bool and
#
#
#
# [0&&7] #logical and
# [0||1] #logical or
3. 参数的使用
#!/bin/bash
echo "$0"
echo "$1"
echo "$2"
echo "$3"
#argu numbers
echo $#
#the current pid
echo $$
#后台运行的最后一个进程的PID
echo $!
#最后一条命令的执行结果,0表示没有错误
echo $?
echo $*
echo $@
#显示shell使用的当前选项
echo $-
echo "$0"
echo "$1"
echo "$2"
echo "$3"
#argu numbers
echo $#
#the current pid
echo $$
#后台运行的最后一个进程的PID
echo $!
#最后一条命令的执行结果,0表示没有错误
echo $?
echo $*
echo $@
#显示shell使用的当前选项
echo $-
4.函数
[ function ] funname [()]{ action; [return int;]}文件包含:
source filename
阅读全文
0 0
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell 脚本
- SHELL 脚本
- shell脚本
- shell脚本
- shell 脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- shell脚本
- 学习zero-shot learning中Xtest的分类去向的一点点小理解
- 分享若干种模态窗口的实现方法
- codeforce 777 C. Alyona and Spreadsheet (打表预处理)
- Framework中的连接管理机制
- Spring boot集成shiro使用Ajax方式,最详细教程
- shell脚本
- C++ 构造函数、赋值函数、析构函数、右值引用
- 网络编程复习(十):实践----数据通信
- Ubuntu14.04:安装JDK8
- Nginx源码剖析--ngx_cycle_s结构体分析
- GKObstacle
- rdd依赖关系、stage划分、stage任务执行揭秘
- tomcat 返回值一直报405问题
- 学会数据分析仅需8步