标签:shell
1 输入YES打印
INPUT=$1 if [ $INPUT == "YES" ];then echo "Please install LAMP." else echo "Please exit." fi
2 创建用户修改密码并输入到文件中
#!/bin/bash #auto modify user passwd #by author chy for i in 1 2 3 4 5 do useradd chy_$i echo "m_pwd_$i"|passwd --stdin chy_$i echo "用户名/密码:"chy_$i pw_chy_$i >>/tmp/user_list.txt done
3 在上一条命令的基础上循环修改密码
[root@192 sh]# more for_user.sh #!/bin/bash #auto modify user passwd #by author chy for i in chy_1 chy_2 chy_3 chy_4 chy_5 do echo "m_pwd"|passwd --stdin $i echo "用户名/密码:"chy_$i pw_chy_$i >>/tmp/user_list2.txt done 注:echo "m_pwd"|passwd --stdin root //修改root密码
4 求和1-100
#!/bin/sh #auto add 1-100 j=0 for ((i=1;i<=100;i++)) do j=`expr $i + $j` done echo $j
5 找到相关log,然后批量打包
[root@192 sh]# more log.sh #!/bin/sh #auto tar log for i in ` find /var/log -name "*.log" ` do tar -cPzf 2016log.tgz $i echo "压缩" $i done echo "压缩完毕"
6 远程主机批量传输文件,可以用在设置密钥上
[root@192 sh]# more scp.sh #!/bin/sh #auto scp files for client #by authors chy 2016 for i in 131 135 do scp /root/test.txt root@192.168.57.$i:/root done
标签:shell
原文地址:http://6874869.blog.51cto.com/6864869/1877941