`

批量删除Ofbiz自写的源代码

阅读更多
因为需要用到无代码的部署,所以写了一个小脚本删除ofbiz的源代码,只限hot-deploy目录下的,当然,这个有待改进
 
#!/bin/sh
 
hd="./hot-deploy"
if [ -d "$hd" ]; then 
    echo "into hot-deploy directory";
    cd hot-deploy
    echo "find all component";
    for file in ./*
    do
        if test -d $file
        then
            echo "find ${file} component,ready delete it."
            cd $file
            rm -rf src/*
        fi
    done
else
    echo "无 hot-deploy 文件夹,跳出";
fi  
 
echo "all done"
 
 
下面这个版本是删除所有.java的源代码,比较极端一点,各取所需吧
 

 

 

 

#!/bin/bash 
SPATH="hot-deploy" 
 
# 函数开始部分
CYCLING(){ 
  filelist=`ls -1` 
  
  for filename in $filelist ; do  
    if [ -f $filename ] ; then  
        if [ "${filename##*.}" "java" ] ; then
            echo "find java source :${filename} ;ready delete it."
            #rm -rf $filename;
        fi
    elif [ -d $filename ] ; then 
        cd $filename 
        SPATH=`pwd
        # Next for recurse 如果遇到目录进行自我调用。。。实现深层遍历
        CYCLING 
  
        # Next Usag: basename dirname 
        SPATH=`dirname $SPATH
        cd $SPATH 
    fi 
  done 
  
# 命令开始部分
cd $SPATH 
CYCLING 
 
echo "All Done."

 

1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics