[svlug] Excluding files from tar
Robert Hajime Lanning
lanning at lanning.cc
Thu Oct 6 00:05:48 PDT 2005
<quote who="Skip Evans">
> tar cvf --exclude upload/* cutemeter.tar *
> tar cvf cutemeter.tar * --exclude upload/*
Ok, people have already givin commands that work, but...
The actual issue is that the shell was expanding the "upload/*"
So, the commandline was:
tar cvf cutemeter.tar <everything in current directory except "." files>\
--exclude upload/<file1> upload/<file2> ...
The --exclude was only taking the first file in the uploads directory
as it's pattern.
To actually pass the pattern into tar, you would need to either escape
the "*" or place it in quotes.
tar cvf cutemeter.tar * --exclude upload/\*
tar cvf cutemeter.tar * --exclude "upload/*"
Also, some side effects... "*" expands to zero or more of any character,
except when used alone in the filespec. "*" alone expands to all files
except the ones that start with a ".". So, if you have files like,
".htaccess", they will not be picked up.
Now, since tar recurses through directories, you can use ".". "." is
a hardlink to the current directory. So, to easily get all files in
the current directory, without the side effects of shell expansion,
you can use ".". This also gets around maximum command line length
when you have too many files in the directory to list on the
And, did Guloka think the Ulus were too ugly to save?
More information about the svlug