脚本自动判断关键字,符合的自动scp

#! /bin/bash
#write by lengxuezhixuan
KEYPATH=/bak/ ftp/keyrbf.dat
SOFFILE=$(find /share/computer/test/rbf -name "*.sof")
FILE=$(find /share/computer/test/rbf/ -size 2146c -a -name "*.rbf")
#FILENAME=`$FILE | awk -F "/" '{print $7}'`
RBFDIR=$(find $FILE |  awk -F "." '{print $2}' | uniq)
strings $SOFFILE | head -n5 > /tmp/rbfs
for i in $FILE
do
        OWNER=$(ls -l | awk -F " " '{print $3}')
        if [ `/usr/bin/file $i | awk -F " " '{print $2}'`="data" ]
        then
                for j in $(cat $KEYPATH)
                do
                        grep -i -w $j /tmp/rbfs >/dev/null
        #        if [ $?="1" -o $?="0" ]
                if [ $?="1" ]
                then
                        /usr/bin/scp $i [email protected]:computer/autosync/$RBFDIR/ --password-file=/bak/ftp/rsyncd.pass
                        echo "yes"
                        /bin/mv ${i} /project/ unix/volume/exchange/archive/ftp/${RBFDIR}
                else
                        echo "`/bin/date +%Y%m%d-%H:%M:%S` ${i}_${OWNER}__grep-error " >> /bak/ftp/nosyncrbf.log
                        echo "no-0"
                fi
                done
        else
                echo "`/bin/date +%Y%m%d-%H:%M:%S` ${i}_${OWNER}__grep-error " >> /bak/ftp/nosyncrbf.log
                echo "no-grep"
        fi

你可能感兴趣的:(操作系统)