remove hijack files within the clearcase server

1271阅读 0评论2009-04-30 vincent-cws
分类:LINUX

#! /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 "$@"

上一篇:MTK integrated serially
下一篇:backup data automatically