Loop se a instrução find não estiver funcionando

0

Eu tenho esse loop "case" no final de um script sh que deve funcionar como mais limpo, mas não, abaixo do código que estou usando

TARGET_DMPDIR='sqlplus -s "/as sysdba" <<EOF
    SET PAGESIZE 0
    SET LINESIZE 200
    SET HEADING OFF
    SET FEEDBACK OFF
    SET TRIMSPOOL ON
    SET FEED OFF
    SET VERIFY OFF
    select directory_path from dba_directories where directory_name='DATA_PUMP_DIR';
    exit;
EOF'
DATE='date +"%Y%m%d-%H%M%S"' 
COMPRESSED_EXPORTFILE="${ORACLE_SID}_${DATE}.dmp" (before the export)
COMPRESSED_EXPORTFILE=${COMPRESSED_EXPORTFILE}.Z (after export)



    case "$ORACLE_SID" in
        LIVE) t=6 ;;
        *)    t=1 ;;
    esac

    find "$TARGET_DMPDIR" -type f '(' -name "$COMPRESSED_EXPORTFILE" -o -name "exp_*_$ORACLE_SID.log" ')' \
        -mtime +"$t" -print -exec rm {} \;

Isso é o que eu tenho no meu TARGET_DMPDIR:

-rw-r-----   1 oracle   dba       814252 Mar  7 21:08 LIVE_20180307-210159.dmp.Z
-rw-r-----   1 oracle   dba       819516 Mar  8 21:09 LIVE_20180308-210202.dmp.Z
-rw-r-----   1 oracle   dba       814493 Mar  9 21:08 LIVE_20180309-210158.dmp.Z
-rw-r--r--   1 oracle   dba         3167 Mar  9 21:08 exp_20180309_LIVE.log
-rw-r-----   1 oracle   dba       820402 Mar 10 21:08 LIVE_20180310-210157.dmp.Z
-rw-r--r--   1 oracle   dba         3169 Mar 10 21:08 exp_20180310_LIVE.log
-rw-r-----   1 oracle   dba       822035 Mar 11 21:08 LIVE_20180311-210158.dmp.Z
-rw-r--r--   1 oracle   dba         3169 Mar 11 21:08 exp_20180311_LIVE.log
-rw-r-----   1 oracle   dba       814219 Mar 12 21:08 LIVE_20180312-210157.dmp.Z
-rw-r--r--   1 oracle   dba         3169 Mar 12 21:08 exp_20180312_LIVE.log
-rw-r-----   1 oracle   dba      21725862211 Mar 14 00:13 LIVE_20180313-212553.dmp.Z
-rw-r--r--   1 oracle   dba       172259 Mar 14 00:13 exp_20180313_LIVE.log
-rw-r-----   1 oracle   dba      21751392439 Mar 15 00:13 LIVE_20180314-212558.dmp.Z
-rw-r--r--   1 oracle   dba       172259 Mar 15 00:13 exp_20180314_LIVE.log
-rw-r-----   1 oracle   dba      21773328817 Mar 16 00:14 LIVE_20180315-212518.dmp.Z
-rw-r--r--   1 oracle   dba       172259 Mar 16 00:14 exp_20180315_LIVE.log
    
por FaMontyN2 02.03.2018 / 11:40

0 respostas