lundi 30 novembre 2015

Find sell script - logs (SUSE Linux, bash, if, find)

Sorry for my English. I have a problem with find sell script. My scrpit finds archives ten unpack some logs tar the results move it level up and remove file that were created in progres. And there is a problem it will do all operation even when script didn't find archive or logs in rsults creating empty tar. i was to fix it using if-statment or && and || operators but i can't handle it could you please direct me how to do it ?

this is my script:

#!/bin/bash

printf " -----\nSerch date: $1 \n"
printf "Serch patern: $2 \n"
printf "serch patern: $3 \n -----\n\n"

printf "Serch archives:\n"
mkdir /cc/xx/logs/aaa/envelop/tmp

find archives/ -name "$1_*_messages.tar.gz" -exec cp {} tmp \;
    ls -l tmp/
    cd tmp
    tar -xf $1_*_messages.tar.gz --wildcards --no-anchored "*$2_$3*"
    printf "Find envelop:\n"
    ls -l alsb-message/

    mv alsb-message $1_$2_$3
    tar -cvf $1_$2_$3.tar $1_$2_$3
    mv $1_$2_$3.tar ..
    rm *.gz
    rm -R $1_$2_$3
    cd ..
    rm -r tmp

Aucun commentaire:

Enregistrer un commentaire