亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: 怎樣交互式執(zhí)行已經(jīng)存在腳本 [打印本頁]

作者: 草_香    時(shí)間: 2013-06-13 19:37
標(biāo)題: 怎樣交互式執(zhí)行已經(jīng)存在腳本
剛開始學(xué)習(xí)shell知識(shí),想實(shí)現(xiàn)一個(gè)功能:
編寫腳本A.sh,執(zhí)行A.sh時(shí)交互出現(xiàn)1、2、3,選擇1的話執(zhí)行當(dāng)前已經(jīng)存在指定的1.sh,選擇2的話執(zhí)行當(dāng)前已經(jīng)存在指定的2.sh,選擇3的話執(zhí)行當(dāng)前已經(jīng)存在指定的4.sh,select可以實(shí)現(xiàn)這個(gè)功能么,不會(huì)寫,請(qǐng)問下各位怎么編寫A.sh可以實(shí)現(xiàn)這個(gè)功能啊,謝謝了~~:wink:
作者: cao627    時(shí)間: 2013-06-13 21:16
  1. #!/bin/bash
  2. while echo "select a scrpt to run"
  3. do

  4. select script in "1.sh" "2.sh" "quit"
  5. do

  6. case $script  in
  7. "1.sh")  sh 1.sh;;
  8. "2.sh")  sh 2.sh;;
  9. "quit") exit 0;;
  10. *) continue;;
  11. esac

  12. break
  13. done

  14. done
復(fù)制代碼

作者: 草_香    時(shí)間: 2013-06-14 09:43
回復(fù) 2# cao627
謝謝了,我去試試去 你可以去百度一下我這個(gè)問題,我提了30分 我給你分,問題名稱:怎樣交互式執(zhí)行已經(jīng)存在腳本

作者: mmwobuaini    時(shí)間: 2013-06-14 20:51
  1. [root@localhost tmp]# cat 1.sh
  2. #!/bin/sh
  3. echo "it is 1.sh"
  4. [root@localhost tmp]# cat 2.sh
  5. #!/bin/sh
  6. echo "it is 2.sh"
  7. [root@localhost tmp]# cat 4.sh
  8. #!/bin/sh
  9. echo "it is 4.sh"
  10. [root@localhost tmp]# cat A.sh
  11. #!/bin/sh
  12. echo -e "make your choice\n1 1.sh\n2 2.sh\n3 4.sh"
  13. read i
  14. case $i in
  15. 1)
  16. /tmp/1.sh
  17. ;;
  18. 2)
  19. /tmp/2.sh
  20. ;;
  21. 3)
  22. /tmp/4.sh
  23. ;;
  24. esac
  25. [root@localhost tmp]# ./A.sh
  26. make your choice
  27. 1 1.sh
  28. 2 2.sh
  29. 3 4.sh
  30. 2
  31. it is 2.sh
復(fù)制代碼
希望能幫到你




歡迎光臨 Chinaunix (http://www.72891.cn/) Powered by Discuz! X3.2