23decxf 发表于 2018-8-27 08:24:31

shell 基本应用及例子(二)

  # cat for.sh
  #!/bin/sh
  for i in $(seq 10)
  do
  echo $i
  done
  # sh for.sh
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  ························
  命令行执行:
  # for i in $(seq 10); do echo $i;done
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  ################################################################
  # cat cc.sh
  #!/bin/bash
  read -p "PLEASE input country:" cou
  read -p "PLEASE input city:" city
  read -p "PLEASE input name:"name
  #echo "$cou,$city,$name"
  date=$(date +%Y)
  #echo $date
  date2=$(date +%m%d)
  #    echo $date2
  if [ -d "./$cou/$city/$name/$date/$date2" ];then
  echo "the dir is exit"
  else
  mkdir -p ./$cou/$city/$name/$date/$date2
  fi
  ··············
  # sh cc.sh
  PLEASE input country:CN
  PLEASE input city:bj
  PLEASE input name:zh
  结果:
  # ll CN/bj/zh/2016/1120/

页: [1]
查看完整版本: shell 基本应用及例子(二)