remove file which suffix with .ptl

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

#! /bin/sh -

foreach_dir () {
    for file in $1/*
    do
        if [ -d "$file" ]; then
       dir_name="$(basename $file)"
       if [ "${dir_name#_arm9e_}" != "$dir_name" ]; then
          basepath="$(dirname $file)"
          path_name=$(dirname $basepath)
          temp=${path_name#*modules/}
          module_name=${temp%%/*}
          gen_file="$basepath/$module_name.gen"
          if [ -f "$gen_file" ]; then
             /bin/grep 'TYPE=void' "$gen_file"
         if [ $? -ne 0 ] ; then
             /bin/rm $file/*
             if [ $? -eq 0 ]; then
             echo "DIR: $file/*.*  -- remove success!"
             echo "DIR: $file/*.*  -- remove success!" >>  ~/remove_ptl.log
             else
             echo "DIR: $file/*.*  -- remove failed!"
             echo "DIR: $file/*.*  -- remove failed!" >> ~/remove_ptl.log
             fi
         else
             echo "xxxxxxxxxxxxxxxxxx" > /dev/null
         fi    
          fi
       fi
           foreach_dir "$file"
        else
    #do something here
        echo "ok" > /dev/null
     fi
    done
}

/bin/touch ~/remove_ptl.log

foreach_dir "$@"

上一篇:clearcase create branch
下一篇:MTK integrated serially