首页 > 系统服务 > 详细

[shell]简单的shell提示和参数脚本

时间:2017-05-23 13:37:41      阅读:247      评论:0      收藏:0      [点我收藏+]

 该shell脚本有如下点:

  • bash or dash
  • case语句的写法
  • 脚本help写法
  • 参数是否为空的写法
  • 参数
#! /bin/bash
case "$1" in
    -h|--help|?)
    echo "Usage: 1st arg:pin name, 2st arg:reset time"
    echo "1st arg pin name:lte-reset,zigbee-reset"
    echo "2st arg reset time in ms"
    exit 0 
;;
esac

if [ ! -n "$1" ]; then
    echo "pls input 1st arg"
    exit
fi


if [ ! -n "$2" ]; then
    echo "pls input 2st arg"
    exit
fi

echo "you will reset $1 with $2ms"
echo 0 > /home/gpio/$1
time=$[ $2 * 1000 ] 
echo $time > /home/gpio/$1

 

[shell]简单的shell提示和参数脚本

原文:http://www.cnblogs.com/aaronLinux/p/6893589.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!