Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: UNIX OT: exclude files in tar

Re: UNIX OT: exclude files in tar

From: <Brian_P_MacLean_at_eFunds.Com>
Date: Mon, 24 Nov 2003 22:24:26 -0800
Message-ID: <F001.005D7A7B.20031124222426@fatcity.com>

Just another excuse to read the tar man page. This series of commands seamed to work in testing. Note the "excluded" and "OK" on the tar command output. As the tar man page states, be careful on the leading and trailing spaces in the exclude file. As with most Unix commands, DON'T use a "-" in the exclude file name, doing so will lead you to question your own sanity when things just don't seam to work right.

mkdir -p level.1/level.2.1/level.2.1.1 \
         level.1/level.2.1/level.2.1.2 \
         level.1/level.2.2/level.2.2.1 \
         level.1/level.2.3/level.2.3.1
touch level.1/level.2.1/level.2.1.1/yes.level.2.1.1 \
      level.1/level.2.1/level.2.1.2/no.level.2.1.1  \
      level.1/level.2.2/yes.2.2.1                   \
      level.1/level.2.2/level.2.2.1/no.2.2.1        \
      level.1/level.2.3/level.2.3.1/yes.2.3.1
echo "level.1/level.2.1/level.2.1.2"  >exclude.file
echo "level.1/level.2.2/level.2.2.1" >>exclude.file tar -cvfX myfiles.tar exclude.file level.1 tar -tvf myfiles.tar
find . -name '*' -type f
ls -Fla
uname -a

24956:oracle_at_bigkahuna> tar -cvfX myfiles.tar exclude.file level.1

a level.1/ 0K
a level.1/level.2.1/ 0K
a level.1/level.2.1/level.2.1.1/ 0K
a level.1/level.2.1/level.2.1.1/yes.level.2.1.1 0K
a level.1/level.2.1/level.2.1.2 excluded
a level.1/level.2.2/ 0K
a level.1/level.2.2/level.2.2.1 excluded
a level.1/level.2.2/yes.2.2.1 0K
a level.1/level.2.3/ 0K
a level.1/level.2.3/level.2.3.1/ 0K
a level.1/level.2.3/level.2.3.1/yes.2.3.1 0K

24956:oracle_at_bigkahuna> tar -tvf myfiles.tar tar: blocksize = 11

drwxr-xr-x 101/2000      0 Nov 24 22:46 2003 level.1/
drwxr-xr-x 101/2000      0 Nov 24 22:46 2003 level.1/level.2.1/
drwxr-xr-x 101/2000      0 Nov 24 22:46 2003 level.1/level.2.1/level.2.1.1/
-rw-r--r-- 101/2000      0 Nov 24 22:46 2003
level.1/level.2.1/level.2.1.1/yes.level.2.1.1
drwxr-xr-x 101/2000      0 Nov 24 22:46 2003 level.1/level.2.2/
-rw-r--r-- 101/2000      0 Nov 24 22:46 2003 level.1/level.2.2/yes.2.2.1
drwxr-xr-x 101/2000      0 Nov 24 22:46 2003 level.1/level.2.3/
drwxr-xr-x 101/2000      0 Nov 24 22:46 2003 level.1/level.2.3/level.2.3.1/
-rw-r--r-- 101/2000      0 Nov 24 22:46 2003
level.1/level.2.3/level.2.3.1/yes.2.3.1
24956:oracle_at_bigkahuna> find . -name '*' -type f
./level.1/level.2.1/level.2.1.1/yes.level.2.1.1
./level.1/level.2.1/level.2.1.2/no.level.2.1.1
./level.1/level.2.2/level.2.2.1/no.2.2.1
./level.1/level.2.2/yes.2.2.1
./level.1/level.2.3/level.2.3.1/yes.2.3.1
./myfiles.tar
./exclude.file

24956:oracle_at_bigkahuna> ls -Fla
total 80

drwxr-xr-x   3 oracle   dba          318 Nov 24 22:52 ./
drwxrwxrwt  13 root     sys         8057 Nov 24 22:59 ../
-rw-r--r--   1 oracle   dba           60 Nov 24 22:46 exclude.file
drwxr-xr-x   5 oracle   dba          315 Nov 24 22:46 level.1/
-rw-r--r--   1 oracle   dba         5632 Nov 24 22:53 myfiles.tar

24956:oracle_at_bigkahuna> uname -a
SunOS bigkahuna 5.8 Generic_108528-22 sun4u sparc SUNW,Ultra-Enterprise

                                                                                                                          
                      Ross Collado                                                                                        
                      <Ross.Collado_at_tec        To:       Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>      
                      hpac.com>                cc:                                                                        
                      Sent by:                 Subject:  UNIX OT: exclude files in tar                                    
                      ml-errors_at_fatcity                                                                                   
                      .com                                                                                                
                                                                                                                          
                                                                                                                          
                      11/24/2003 10:24                                                                                    
                      PM                                                                                                  
                      Please respond to                                                                                   
                      ORACLE-L                                                                                            
                                                                                                                          
                                                                                                                          




Hello,

On Solaris 8

I can't seem to get the tar command right. I wanted to tar a directory but EXCLUDE one of the subdirectory in it.
Example:
/home/user01
/home/user01/mark01
/home/user01/mark01/ask.txt
/home/user01/mark01/ghost.txt
/home/user01/mark02
/home/user01/mark02/ask.txt
/home/user01/mark02/ghost.txt
/home/user01/mark03
/home/user01/mark03/ask.txt
/home/user01/mark03/ghost.txt

I wanted to tar everything except /home/user01/mark03/* man pages on tar says there is an option to exclude files but I just can't get it to work for me.

Can someone show me how to do this right?

Thanks,
Ross

--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Ross Collado
  INET: Ross.Collado_at_techpac.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).





-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: 
  INET: Brian_P_MacLean_at_eFunds.Com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Tue Nov 25 2003 - 00:24:26 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US