zoukankan      html  css  js  c++  java
  • 阿铭每日一题 day 2 20180112

    方法一:

     1 #!/bin/bash
     2 
     3 echo "*cmd meau** 1--date 2--ls 3--who 4--pwd"
     4 read -p "Please input number:" number
     5 case $number in
     6 1)
     7 date
     8 ;;
     9 2)
    10 ls
    11 ;;
    12 3)
    13 who
    14 ;;
    15 4)
    16 pwd
    17 ;;
    18 *)
    19 echo -e "
    "
    20 echo "Please input number 1-4!!!"
    21 ;;
    22 esac

    方法二:

     1 #!/bin/bash
     2 echo "Pleae chose a number"
     3 select number in date ls who pwd
     4 do
     5 case $number in
     6 date)
     7     date
     8     ;;
     9 ls)
    10     ls
    11     ;;
    12 who)
    13     who
    14     ;;
    15 pwd)
    16     pwd
    17     ;;
    18 *)
    19     echo "Please inpurt number 1-4"
    20     ;;
    21 esac
    22 done
     
    day2 解析:
    1、使用case语法就可以实现啦,不用想的太复杂
     
    day2=参考答案=~ps.不是唯一答案哦

     1 #!/bin/bash
     2 echo "*cmd meau** 1--date 2--ls 3--who 4--pwd"
     3 read -p "Please input number:" number
     4 case $number in
     5 1)
     6 date
     7 ;;
     8 2)
     9 ls
    10 ;;
    11 3)
    12 who
    13 ;;
    14 4)
    15 pwd
    16 ;;
    17 *)
    18 echo -e "
    "
    19 echo "Please input number 1-4!!!"
    20 ;;
    21 esac
  • 相关阅读:
    并查集
    强联通分量,缩点
    最短路径
    最小生成树
    拓扑排序
    图的遍历
    图论基础知识
    数据库四种隔离级别
    MySQL 索引 乐观锁 悲观锁
    MYSQL+正则
  • 原文地址:https://www.cnblogs.com/ivan-yang/p/8323523.html
Copyright © 2011-2022 走看看