1. 程式人生 > >[shell]簡單的shell提示和參數腳本

[shell]簡單的shell提示和參數腳本

log help pre col home bsp 腳本 $1 是否

該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提示和參數腳本