Chinaunix首页 | 论坛 | 博客
  • 博客访问: 897690
  • 博文数量: 116
  • 博客积分: 3923
  • 博客等级: 中校
  • 技术积分: 1337
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-23 01:22
文章分类

全部博文(116)

文章存档

2013年(1)

2012年(17)

2011年(69)

2009年(29)

分类: LINUX

2009-04-30 21:46:59

#! /usr/bin/bash -
#################################################################################################################
# file_name: remove_hijack
# Author   : Vincent.chen
# Date     : 2009-03-31
# Platform : Cygwin Platform
# Usage    : step 1: First, compile the project and then update the view.
#            step 2: Second, undo hijack files and then make hijack file have
#                    (xxx.keep) of it's counterpart
#            step 3: run this script  
#################################################################################################################

# recurse find the file suffix with tag .keep and delete it from clearcase
do_recursive()
{
    cd $1
    for filename in `ls`
    do
         if [ -d "$filename" ]; then
             do_recursive "$filename"
         cd ..
     else
         prename=${filename%.keep}
         if [ "$prename" != "$filename" ]; then
         echo "`pwd`/$filename ===> $prename"
         rm -f "$prename"
#         cleartool rmelem -nc -f "$prename"
         count=`expr ${count} + 1`
         fi
         fi
    done
    return 0
}

delete_hijack()
{
    PARAMS=1
    if [ $# -ne $PARAMS ]
    then
        echo "usage: remove_hijack your_dir_name"
        return 1
    fi
    count=0
    if [ -d "$1" ]
    then
    cd "$1"
    else
    echo "$1 is not a directory!!"
    return 0
    fi

    do_recursive "$1"
    echo "complete! $count hijack files have been deleted."

    return 0
}

delete_hijack "$@"

阅读(1056) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~