LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   tar --exclude-from=FILE (https://www.linuxquestions.org/questions/programming-9/tar-exclude-from%3Dfile-348071/)

GATTACA 07-29-2005 11:42 AM

tar --exclude-from=FILE
 
I'm trying to get tar to pack up only certain files in a directory.

I my approach is that I have a file in my home space called .skip_files (<- note the dot at the beginnig of name).

Anyway lets say a directory contains the following:

file1.txt
file2.txt
avoid1.txt
avoid2.txt
extra-directory-1
extra-directory-2
avoid-directory-1

I want tar to include in a tarball everything that does not contain "avoid" in its name. Now in ~/.skip_files I've added the names of the files and directories I want to skip

When I execute: tar -czvf stuff.tar.gz --exclude-from=~/.skip_files target_directory

it never works.

I've tried variations of the command such as:
tar -czf stuff.tar.gz --exclude-from=~/.skip_files target_directory
tar -czf stuff.tar.gz target_directory --exclude-from=~/.skip_files

I'm sure there is a simple solution to this problem I just can see it.

Any suggestions?

Quigi 07-29-2005 12:25 PM

In your command, "~" isn't expanded. You told us you mean your home directory, so use either of
Code:

--exclude-from ~/.skip_files
--exclude-from=$HOME/.skip_files

As written, .skip_files would need to sit in a local sub-directory by the name "~".


All times are GMT -5. The time now is 07:13 AM.