ienki 发表于 2018-8-25 12:06:11

简单shell脚本

  简单的shell脚本案例
  测试段内存活的主机数
  #!/bin/bash
  for n in {1..20}; do
  host=192.168.0.$n
  ping -c2 $host &> /dev/null
  if [ $? = 0 ]; then
  ehco "$host is UP"
  else
  echo "$host is DOWN"
  fi
  done
  批量添加用户
  #!/bin/bash
  for number in $(seq 1 10)
  do
  USER=user$number
  useradd $USER
  echopassword | passwd --stdin $USER
  done

页: [1]
查看完整版本: 简单shell脚本