如何获取shell脚本的可选参数
来源:互联网 发布:网络成瘾的症状 编辑:程序博客网 时间:2024/06/05 22:32
直接上例子:
cat option_sh #!/bin/bashecho $*# get the optional argumentswhile getopts f:t: valuedo case $value in f ) RHOST_INFO=$OPTARG # 从$OPTARG中获得参数值 ;; t ) TIMEOUT=$OPTARG ;; esacdoneecho $@shift $(($OPTIND-1)) # 偏移至后面的参数echo $*echo $1if [ $TIMEOUT == "30" ] # 获得的参数为字符串thenecho here fingnlinux1 [** NONE **]/home/qius $ ngnlinux1 [** NONE **]/home/qius $ ./option_sh -t 30 -f ss other paras-t 30 -f ss other paras-t 30 -f ss other paras
other paras
other
here使用方法:example.sh -f file_name -t timeoutvalue other paras
- 如何获取shell脚本的可选参数
- shell脚本中如何获取命令的参数(1)
- shell脚本之参数的获取
- shell脚本中如何获取命令的参数(2) ----处理命令参数
- 如何访问Shell脚本的参数
- shell脚本的参数
- shell脚本:访问shell脚本的参数
- python 如何调用带参数的shell脚本
- Getopts获取shell脚本命令行参数
- linux下shell脚本获取网卡参数
- Getopts获取shell脚本命令行参数
- 脚本获取输入参数shell之getopt
- Shell脚本基础4-shell脚本如何传参数
- shell脚本的参数问题
- Shell脚本的一些参数
- Shell脚本的参数传递
- 函数的可选参数
- Java的可选参数
- Redhat (CentOS) 建本地yum源
- nyoj 38 布线问题
- 修改虚拟机共享文件夹路径/mnt/hgfs
- 利用Flash读取SQL Server数据库的值
- nutch爬去是出现NullPointException问题
- 如何获取shell脚本的可选参数
- 操作系统概念
- 软考书籍
- partial将一个类分散到多个.cs文件中
- Toad for Oracle 11
- 2012 Multi-University Training Contest 2
- Amazon Simple Storage Service(Amazon S3)
- 移植zlib1.1.4
- 如何制作和使用Jffs2文件系统