自动生成linux下的产品上线文件

    如果你是一个软件开发人员,如果你是一个经常做产品上线操作的程序员,你一定会对tar命令很熟悉,它是一个打包命令,但具体的打包内容可能是一个很长的文件列表,如果部分文件上线的话人工制作一个文件列表是一件很浪费精力的事情。

 

    于是我写了一个shell脚本,用来查找自上一次上线后更新的文件,只需要输入上次上线的前一天,即可自动生成一个文件列表,程序代码如下:

#!/bin/sh

FILE_HOME="/app/gau/www";

>/app/gau/wesley/uid.tmp;

 

awk 'BEGIN{

    printf "Do you confirm this is the FILE_HOME:{'"$FILE_HOME"'}?"

       getline result > "/dev/tty" ;

       while( result != "yes" )

       {  

              printf "please reset the FILE_HOME in this shell script.../n"      

              uid="`id -u`"                 

              system("ps -u '"$uid"' -f | grep '"get_latest_files"' | egrep -v '"awk"' | egrep -v '"vi"' | egrep -v '"grep"' > /app/gau/wesley/uid.tmp")           

              exit;

       }

}';

 

cnt=`cat /app/gau/wesley/uid.tmp | wc -l`           

while [ $cnt -gt 0 ] ; do

       line=`sed -n "${cnt}p" /app/gau/wesley/uid.tmp`

       pid=`echo $line| cut -d " " -f2`

       kill -9 $pid

       echo stop $pid

       cnt=`expr $cnt-1`

done

 

echo "please input the last date of the tag_date,date format is like 2010-03-01...";

eval $( awk '{

                       getline date1 > "/dev/tty" ;

                       printf "date1="date1;

                       exit;

                      }';               

         );

echo "find the files modified before $date1";

 

find $FILE_HOME -type f -ctime -$(echo " ( $(date +%s) - $(date +%s -d $date1)) / ( 3600 * 24 ) " | bc) > /app/gau/wesley/file_list.log;

 

sed 's///app//gau /g' /app/gau/wesley/file_list.log > /app/gau/wesley/file_list_tmp.log;

sed '/www//gau//WEB-INF//classes/d' /app/gau/wesley/file_list_tmp.log > /app/gau/wesley/file_list_tmp1.log;

sed '/www//gau//MerKey/d' /app/gau/wesley/file_list_tmp1.log > /app/gau/wesley/file_list.log;

 

rm /app/gau/wesley/file_list_tmp.log;

rm /app/gau/wesley/file_list_tmp1.log;

 

代码比较粗糙,如果有不明白或有新的建议请联系我; E-Mail: wesleyzhong007@gmail.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值