简单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
echo  password | passwd --stdin $USER
done
   

你可能感兴趣的:(linux,shell,职场,休闲)