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
Andrew
Please advise, Thanks
Andrew
You can use the -L option.Quote:>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
>Andrew
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
1. Using tar: How to exclude certain Directories/Files?
Hi, Everyone,
Our system is Sparc Solaris 2.6.
Sometimes there is a need to partially copy a directory.
if I use
# tar cf - /fromdir | ( cd /todir; tar xf -)
the problem is that I only want copy most subdirectories within /fromdir,
how can exclude serveral directories I don't want? i.e.
Suppose there are 200 files and directories inside /fromdir, I want copy
most files and diretories except file File1 and directory Dir1 (because Dir1
is too big to fit in /todir), I would type:
# tar cf - /fromdir -X File1 -X Dir1 | (cd /todir; tar xf -)
The command doesn't work and thinks X is a file.
Can anybody please tell me how to use X (Exclude) function in tar?
Thanks a lot in advance.
Sean Zhang
3. Excluding directories from tar files
4. need some help with ls command
5. Excluding file with given extension from a tar file
6. Problem reading binary file from CD-ROM.
7. Directory List of files excluding files without a suffix
9. How to exclude files in tar
10. excluding files from tar creation using wildcards
11. Problem excluding TAR files
12. TAR - exclude from file (again)
13. how do i make tar exclude a file?