[linux Shell] 判断当前运行的参数的个数
2014-01-12 18:10
190 查看
1.
$1--代表第一个参数
-n --表示非none
#!/bin/sh
if [ -n "$1" ]
then
echo "has params\n"
else
echo "no params"
fi
2.
$#代表参数个数
-ne表示非空且等于 not none and equal
if [ $# -ne 2 ]
then
echo "has params"
else
echo "no params"
fi
$1--代表第一个参数
-n --表示非none
#!/bin/sh
if [ -n "$1" ]
then
echo "has params\n"
else
echo "no params"
fi
2.
$#代表参数个数
-ne表示非空且等于 not none and equal
if [ $# -ne 2 ]
then
echo "has params"
else
echo "no params"
fi
相关文章推荐
- [linux Shell] 判断当前运行的参数的个数
- linux shell 编程4 判断当前的是不是目录、 传递参数的个数
- 判断当前进程是否"以管理员身份运行"的
- 判断当前task中的运行的activity是否为当前应用
- linux shell脚本编程if语句内判断参数详解
- retrofit2中判断当前运行的环境代码--优美代码
- 判断当前进程是否"以管理员身份运行"的
- 判断当前进程是否以管理员权限运行(AllocateAndInitializeSid后,用CheckTokenMembership与AdministratorsGroup进行比较,和Delphi的那个例子还有点不一样)
- windows XP下查看当前系统运行进程的运行参数 (CMD)
- 使用SQL判断当前JOB是否在运行
- 判断当前应用是否是后台运行
- linux shell 判断参数
- linux shell判断程序是否运行,没有运行则运行程序
- linux shell编程if语句内判断参数详解
- linux shell使用if时判断参数介绍
- Android中getSystemService介绍,获取系统的运行状态,判断当前网络状态
- php 判断当前脚本的运行方式
- 判断当前task中的运行的activity是否为当前应用
- 转 linux shell编程if语句内判断参数
- linux shell编程if语句内判断参数