Shell编程 讲座

来自软件实验室
跳转至: 导航搜索
  • 至于一行显示的内容太多,\Enter延伸至下一行
  • 「#」作为注解
  • 撰写第一支script
  #!/bin/bash
  #Prigram:
  #  This program shows "Hello World!"in your screen.
  #History
  #2005/08/23 VBird First release
    PATH=/bin:/sbin:/usr/bin:/usr/sbin/local/bin::/usr/local/sbin:~/bin
    export PATH
    echo -e"Hello World!\a\n"
    exit 0
  • 运行:sh sh01.sh 或 chmod a+x sh01.sh; ./sh01.sh
  • 撰写第二支script
  1. !/bin/bash
  2. program
  3. User inputs his first name and last name.Program shows his full name.
  4. history:
#2005/08/23 VBird First release
   PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
   export PATH
      
   read -p"Please input your first name:"firstname
   read -p"Please input your last name:"lastname
   echo -e"\nYour full name is:$first name $lastname"