vi.
作者vi.·2011-03-16 11:50
工程师·银海软件

shell编程(caseparam)

字数 672阅读 2023评论 1赞 1
[root@linux4  ]# cat caseparam
#!/bin/sh
#caseparam
if [ $# != 1 ]; then
  echo "Usage:'basename $0'[start|stop|help]" >&2
  exit 1
 fi
# assign the parameter to the variable OPT
OPT=$1
 case $OPT in
 start) echo "starting~~`basename $0`"
 #code here to start a process
 ;;
 stop) echo "stopping~~ `basename $0`"
 #code here to stop a process
 ;;
help)
 #code here to dispaly a help page
;;
 *)echo "Usage:`basename $`[start|stop|help]"
;;
esac
[root@linux4  ]# ./caseparam start
starting~~caseparam
[root@linux4  ]# ./caseparam stop
stopping~~ caseparam
[root@linux4  ]# ./caseparam help
[root@linux4  ]#

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

1

添加新评论1 条评论

mophismophis软件开发工程师杭州
2011-05-09 10:32
兄弟,你在研究shell脚本呀?
Ctrl+Enter 发表

作者其他文章

  • ARP详图
    评论 3 · 赞 5
  • shell编程(日历)
    评论 0 · 赞 0
  • Linix quota (磁盘配额)
    评论 1 · 赞 0
  • HP-UNIX内存及交换空间
    评论 0 · 赞 0
  • Unix与Linux???
    评论 0 · 赞 0
  • X社区推广