Excluding files using tar cXzf


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Excluding files using tar cXzf
# 1  
Old 07-28-2005
Excluding files using tar cXzf

Hi All,

I'm having trouble with creating a compressed tar file with tar cXzfv and even with normal cvXf

I created a simple test below.. can anyone spot the mistake I'm making??.. its driving me up the wall..

In the end I need a compressed tarball....

Thanks in advance!!
Sam

**************************************************************

root@node1 [~/tmp]# ls -R
.:
./ ../ 1_dir/ 2_dir/

./1_dir:
./ ../ 1_1_dir/ 1_file

./1_dir/1_1_dir:
./ ../ 1_1_file

root@node1 [~/tmp]# more exclude_file
./1_dir/1_file
root@node1 [~/tmp]# tar cvf tar.tar 1_dir/
1_dir/
1_dir/1_1_dir/
1_dir/1_1_dir/1_1_file
1_dir/1_file
root@node1 [~/tmp]# rm tar.tar
rm: remove regular file `tar.tar'? y
root@node1 [~/tmp]# tar cvXf exclude_file tar.tar 1_dir/
1_dir/
1_dir/1_1_dir/
1_dir/1_1_dir/1_1_file
1_dir/1_file
# 2  
Old 07-28-2005
I think, in your case, exclude_file contains the list of files which should not be considered for tar.

tar cvf tar.tar --exclude-from exclude_file

Vino
# 3  
Old 07-28-2005
Thanks Vino for the reply...

your right that the file contains the file names that I would like to exclude from the tarball... This was my intension..

i.e. in this example I'm trying to exclude the ./1_dir/1_file file... but it still gets added every time.... see below.. could I have I got path issues in the exclude file??

root@node1 [~/tmp]# tar -cvf tar.tar --exclude-from exclude_file 1_dir/
1_dir/
1_dir/1_1_dir/
1_dir/1_1_dir/1_1_file
1_dir/1_file
root@node1 [~/tmp]# more exclude_file
./1_dir/1_file
root@node1 [~/tmp]#

from man file:
-X, --exclude-from FILE
exclude files listed in FILE
# 4  
Old 07-28-2005
could be also:
tar cvX exclude_file -f new_archive.tar 1_dir/
# 5  
Old 07-28-2005
cheers infierno for the pointer.. but still no luck.. see below... It should be simple but I think I'm going mad.. Smilie

Sam

root@node1 [~/tmp]# tar cvX exclude_file -f new_archive.tar 1_dir/
1_dir/
1_dir/1_1_dir/
1_dir/1_1_dir/1_1_file
1_dir/1_file
root@node1 [~/tmp]# more exclude_file
./1_dir/1_file
root@node1 [~/tmp]# tar -tvf new_archive.tar
drwxr-xr-x root/root 0 2005-07-28 12:33:36 1_dir/
drwxr-xr-x root/root 0 2005-07-28 12:34:08 1_dir/1_1_dir/
-rw-r--r-- root/root 2 2005-07-28 12:37:48 1_dir/1_1_dir/1_1_file
-rw-r--r-- root/root 2 2005-07-28 12:37:34 1_dir/1_file

root@node1 [~/tmp]# tar --version
tar (GNU tar) 1.13.25
Copyright (C) 2001 Free Software Foundation, Inc.
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by John Gilmore and Jay Fenlason.

root@node1 [~/tmp]# cat /proc/version
Linux version 2.4.20-021stab028.12.777-enterprise (st@current.eng.sw.ru) (gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)) #1 SMP Fri May 13 15:50:02 MSD 2005
# 6  
Old 07-28-2005
This might(?) make a difference.

exclude_file should contain only /1_dir/1_file and not ./1_dir/1_file.

vino
# 7  
Old 07-28-2005
tar cvf tar.tar --exclude-from=exclude_file
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Excluding directory in my tar Backup

Hello AIX experts. Hope this topic finds you well :) Now, I will take a backup for a directory called medcbs. Inside this directory 1 subdirectory I don't want to include it in the backup. So, how to exclude it? To be more clear, take a look to the following: /bossapp1/medcbs>... (4 Replies)
Discussion started by: Mohannad
4 Replies

2. Shell Programming and Scripting

How to tar this dir excluding some files .au?

Hi all, Thanks for previous help. How to include this in script, I need to tar files which are present in /var/spool/cron/crontabs directory (used for crontab) excluding those files which are having extension .au /var/spool/cron/crontabs>>ls -ltr | grep -v .au total 438 -rw------- 1... (11 Replies)
Discussion started by: manalisharmabe
11 Replies

3. Shell Programming and Scripting

Create tar file excluding all hard links

I have a problem with tar. Taring a folder with a lot of contents, causes the tar to contain hard links to some files, seen with the same name but 0 in size. The hard links don't exist in the first place. How can I prevent that from happening? I am using the -T option with either -n or... (2 Replies)
Discussion started by: Tribe
2 Replies

4. Shell Programming and Scripting

Excluding file from tar

Hello i am using HP-UX rapdb2 B.11.23 U ia64 1068321383 unlimited-user license. I am tryiyng to exclude for tar all files that start with TOT* but i doues not work I am using: tar -cvf /ODS/prepaid/CDR_FLOW/WORK/backup.tar --exclude='TOT*' and i get the error: tar: cannot stat... (3 Replies)
Discussion started by: chriss_58
3 Replies

5. UNIX for Advanced & Expert Users

Excluding a file from tar...

The title is not as easy as it sounds.... I am trying to exclude and file while ssh and untaring the file on the fly. The command I am using is... The command typically works but recently I've add the X option along with the exclude file. Essentially, the exclude file is being ignored when run... (2 Replies)
Discussion started by: lwif
2 Replies

6. Shell Programming and Scripting

Creating tar excluding links

hi, How do i create a tar file of a directory excluding the links in that particular directory and its sub-directories. The below command doesnt work for me. tar -cvf abc.tar /dir1 --exclude"^l" (1 Reply)
Discussion started by: yesmani
1 Replies

7. UNIX for Dummies Questions & Answers

Creating tar file for subdirs, excluding one and preserving user info

Hi All, I am not one of the super users / root for AIX 5.3 system. There is a filesystem Say /DIR1 and its has several subdirs in it say SUBDIR1, SUBDIR2, SUBDIR3. Can I create a tar file for all files under DIR1 and SUBDIR1, SUBDIR3. Excluding SIBDIR2? Also how can I preserve... (2 Replies)
Discussion started by: Hangman2
2 Replies

8. Shell Programming and Scripting

excluding directories in tar

In a bash script I am writing I am having a problem excluding selected directories from tar. From the machine $SERVER I issue the command #start netcat on storage server gnetcat -l -vv -p 2011 >$FILEPATH/$SHORT_NAME.$today.tar & The the following command is then sent to the $CLIENT. #start... (2 Replies)
Discussion started by: thumper
2 Replies

9. UNIX Desktop Questions & Answers

tar backup with excluding some folders

Hi , I want to backup the root file system but the size of / is very huge so I want to exclude some file systems.Man page of tar says X option excludes files but I could not do that.I use this command $ tar -cvf deneme.tar -X exc . $ cat exc sql kkm I think there... (2 Replies)
Discussion started by: kudret_gulcan
2 Replies

10. UNIX for Dummies Questions & Answers

excluding directories while using tar

How do I exclude some directories while creating a tar file with a number of directories? thanks. (2 Replies)
Discussion started by: uchachra
2 Replies
Login or Register to Ask a Question