njsuntop 发表于 2018-8-20 11:43:36

SHELL编程-Shell编程进阶

  1.1 shell脚本介绍
  shell结构以及执行
  cd shell/
  vim first.sh
  #!/bin/bash
  ##The first test shell script
  ##written by aming.
  ls /tmp/
  echo "This is the first script."
  bash first.sh
  ./first.sh
  sh first.sh
  sh -x first.sh
  date命令
  date日期
  cal
  yum -y install ntp
  ntpdate time.windows.com
  netpdate ntp.fudan.com
  date +%TY ymd H M S s
  date -d "-2 days" +%F
  shell自定义变量
  vim 2.sh
  #!/bin/bash
  ##
  ##
  read -t 3 -p "please input a number: " number
  echo $number
  sh 3.sh
  vim 3.sh
  #! /bing/bash
  ##
  ##
  echo "\$1=$1"
  echo "\$2=$2"
  echo"\$0=$0"
  echo "\$3=$o"
  sh 3.sh
  if逻辑判断
  vim if.sh
  #!/bin/bash
  a=5
  if [ $a -gt 10 ]
  then
  echo "a>10"
  elif [$a -lt 4 ]
  then
  echo "a
页: [1]
查看完整版本: SHELL编程-Shell编程进阶