码迷,mamicode.com
首页 > 其他好文 > 详细

case使用例子

时间:2016-12-29 06:49:57      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:sni   tor   ash   man   用例   class   stat   dir   text   

echo ‘Input a number between 1 to 4‘
echo ‘Your number is:\c‘
read aNum
case $aNum in
    1)  echo ‘You select 1‘
    ;;
    2)  echo ‘You select 2‘
    ;;
    3)  echo ‘You select 3‘
    ;;
    4)  echo ‘You select 4‘
    ;;
    *)  echo ‘You do not select a number between 1 to 4‘
    ;;
esac


#!/bin/bash

option="${1}"
case ${option} in
   -f) FILE="${2}"
      echo "File name is $FILE"
      ;;
   -d) DIR="${2}"
      echo "Dir name is $DIR"
      ;;
   *) 
      echo "`basename ${0}`:usage: [-f file] | [-d directory]"
      exit 1 # Command to come out of the program with status 1
      ;;
esac

case使用例子

标签:sni   tor   ash   man   用例   class   stat   dir   text   

原文地址:http://www.cnblogs.com/chenxiaoyong/p/6230884.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!