It is currently Mon, 23 Apr 2018 08:47:02 GMT

Author Message
 How to exclude files/directory when tar - up a files
I need to tar up a directory, but I want to omit certain files/sub-directory
. How can I do it? In Solaris I can append in a ".Exclude" file, but I cant'
find this option in AIX.

Please advise, Thanks


 Sun, 28 Sep 2003 14:06:59 GMT   
 How to exclude files/directory when tar - up a files
In article <nNRA6.1514$>,
 "News Group" <> writes:

You can use the -L option.

Create a file of filenames that you want included in the tar
archive, one filename per line.  Then list the name of this
file after the -L option.  Tar will only archive exactly what
is listed.  Directories are not recursed.

Building the file of filenames isn't too difficult.  You can
use "find" to build a complete list and then edit the list
by hand.

find dir -print > list
vi list
tar -c -f tar.out -L list

If you need to automate this, you have several options.
You can pipe the list through "grep -v" or "egrep -v"
to take out lines you don't want.

find dir -print | grep -v skipdir > list

find dir -print | egrep -v 'skipdir|nogood' > list

You can get clever with find and have it omit files
you don't want.

find dir ! -name '*.old' -print > list

find dir \( \( -name skipdir -o -name nogood \) -prune \) \
  -o -print > list

For example, suppose you want to archive directory "dir" but
want to skip any file whose name ends with .old.  You could
do it like this:

find dir ! -name '*.old' > list

tar -c -f tar.out -L list

 Mon, 29 Sep 2003 05:25:29 GMT   
   [ 2 post ] 

Similar Threads

1. Using tar: How to exclude certain Directories/Files?

2. Excluding directories from tar files

3. Excluding file with given extension from a tar file

4. Directory List of files excluding files without a suffix

5. how do i make tar exclude a file?

6. tar exclude file issue

7. Excluding files on a tar

8. Exclude-file 'tar' ignores wildcards

9. excluding files while using tar

10. TAR - exclude from file (again)

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software