Linux Articles, Shell Scripts February 24, 2008 0

Compress Oracle Archive logs 10 in 1 sequence

This script will archive and compress Oracle Database Archive Logs into one package of 10 log files.

  • Assumption: files’ name convention is as follows:

sequance 0-9: “dummy_string0-9.arc”

#!/bin/sh

############################################################
# Script will compress "arc files"  10 in one with seq [0-9]  
############################################################

for f in *_*9.arc; do
    [ -f "$f" ] || break;
    ARCHBASE=${f%9.arc}
    tar -cvzf ${ARCHBASE}x.tgz ${ARCHBASE}[0-9].arc
    rm ${ARCHBASE}[0-9].arc
done

#END-SCRIPT#

Let’s create some test data and test the script:

$for i in `seq 0 9`; do touch ARC_5567050500$i.arc; done

now execute the script:

$sh script.sh

As a result we’ve got one compressed package with 10 arc log files:

ARC_5567050500x.tgz

Cheers!!

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close