码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本

时间:2015-09-17 15:30:57      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:shell

[zyzx@ZYZX-DMZ-VIRTUAL-0005 chy]$ cat change.sh
#!/bin/bash
#yu
#
egrep -o "[[:alnum:]]{1,}/src*" a.txt | awk -F"/" ‘{print $1}‘ | sort -u
num=`egrep -o "[[:alnum:]]{1,}/src*" a.txt | awk -F"/" ‘{print $1}‘ | sort -u | wc -l`
echo "Total: $num"
[zyzx@ZYZX-DMZ-VIRTUAL-0005 chy]$ cat create.sh
#!/bin/bash
#yu
#
egrep -o "[[:alnum:]]{1,}/src*" a.txt | awk -F"/" ‘{print $1}‘ | sort -u
num=`egrep -o "[[:alnum:]]{1,}/src*" a.txt | awk -F"/" ‘{print $1}‘ | sort -u | wc -l`
echo "Total: $num"
egrep -o "[[:alnum:]]{1,}/src*" a.txt | awk -F"/" ‘{print $1}‘ | sort -u > b.txt

#create project
for i in `cat b.txt`;do
    read -p "Are you sure create $i? " project
       if [ $project = "yes" ];then
           /home/zyzx/deploy_test/bin/create-$i.sh
       else
          echo "no need create $i."
       fi
done
[zyzx@ZYZX-DMZ-VIRTUAL-0005 chy]$ cat deploy.sh
#!/bin/bash
#yu
#
Date="============`date +%Y%m%d_%H%M`============"
egrep -o "[[:alnum:]]{1,}/src*" a.txt | awk -F"/" ‘{print $1}‘ | sort -u
num=`egrep -o "[[:alnum:]]{1,}/src*" a.txt | awk -F"/" ‘{print $1}‘ | sort -u | wc -l`
echo "Total: $num"
egrep -o "[[:alnum:]]{1,}/src*" a.txt | awk -F"/" ‘{print $1}‘ | sort -u > b.txt

#deploy project
echo $Date > deploy.log
for i in `cat b.txt`;do
  read -p "Are you sure deploy $i? " deploy
    deploylog () {
        echo `cat /home/zyzx/deploy_test/bin/log/deploy-$i.log` >> deploy.log
         }
       if [ $deploy = "yes" ];then
          cd /home/zyzx/deploy_test/bin/
          sh deploy-$i.sh
          deploylog
       elif [ $deploy = "esb_in" ];then
          cd /home/zyzx/deploy_test/bin/
          sh deploy-$i-in.sh
          echo `cat /home/zyzx/deploy_test/bin/log/deploy-esb-in.log` >> deploy.log
       elif [ $deploy = "esb_out" ];then
          cd /home/zyzx/deploy_test/bin/
          sh deploy-$i-out.sh
          echo `cat /home/zyzx/deploy_test/bin/log/deploy-esb-out.log` >> deploy.log
       else
          echo "no need deploy"
        fi
done
more /tmp/chy/deploy.log
[zyzx@ZYZX-DMZ-VIRTUAL-0005 chy]$


[zyzx@ZYZX-DMZ-VIRTUAL-0005 chy]$ cat rmlog.sh
#!/bin/bash
#yu
#
for i in `cat d.txt`;do
   find /home/zyzx/$i/logs/ -mtime +10 -exec rm -rf {} \;
done
[zyzx@ZYZX-DMZ-VIRTUAL-0005 chy]$



shell脚本

标签:shell

原文地址:http://anyulinux.blog.51cto.com/9108882/1695585

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!