shell case esac语句
来源:互联网 发布:linux下echo命令详解 编辑:程序博客网 时间:2024/05/08 09:39
shell脚本如下代码echo 'Input a number between 1 to 4'echo 'Your number is:\c'read aNumcase $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输出结果Input a number between 1 to 4Your number is:3You select 3再举例#!/bin/bashoption="${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$./test.shtest.sh: usage: [ -f filename ] | [ -d directory ]$ ./test.sh -f index.htm$ vi test.sh$ ./test.sh -f index.htmFile name is index.htm$ ./test.sh -d unixDir name is unix$
0 0
- Shell case esac语句
- Shell case esac语句
- Shell case esac语句
- Shell case esac语句
- Shell case esac语句
- Shell case esac语句
- Shell case esac语句
- shell case esac语句
- Shell case esac语句
- 十五、Shell case esac语句
- Shell 学习16 - Shell case esac 语句
- (11)shell case esac语句
- shell case...esac
- shell的case esac
- 【Shell脚本学习17】Shell case esac语句
- Shell 循环语句:if,case esac,for,while
- shell语句中的esac
- Shell case esac 和 for
- Java 接口简述
- 读《漫谈架构》感想
- 解决window.open被浏览器拦截的问题
- storm学习笔记
- c++运算符的优先级表
- shell case esac语句
- HTTP 协议
- Redis 它是什么?它用来做什么?它的优势与短板如何?
- Spring3 整合MyBatis3 配置多数据源 动态选择SqlSessionFactory
- 入门训练 Fibonacci数列
- JSONP接口怎么写?
- 操作系统from清华大学向勇,陈渝 笔记(一)绪论
- 面试遇到的问题总结(一)
- JSON与JS对象的区别