|
|
#1 (permalink) |
|
Registered User
Join Date: Sep 2004
Posts: 35
|
recursive tarball
hey, does anyone know how to omit a few directories when making a tarball recursively.
Lets say Code:
tar -cvzf backup.tar.gz foo_dir Thanks for your time, Dave |
|
|
|
|
|
#2 (permalink) |
|
Da House Nerd
Join Date: Dec 1969
Location: One CPU Lane
Posts: 3,512
|
tar itself can't do it, but I would do it using find. Find can handle regexps.
see man find especially the OPERATORS section. one example from the manual: find / \! -name "*.c" -print Print out a list of all the files whose names do not end in .c. in complete the command would be something like tar -cvzf myfile.tar.gz `find . -name "bla" | xargs` for a backup it might be interesting to use the -j flag instead of the -z flag, since bzip2 compression is much better than gzip compression.
__________________
Linux virusscanner detected a virus: Windows 95 ... delete [Y/n] y ~ ~ :wq |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Sep 2004
Posts: 35
|
hey one more thing greffov. How can I put a regular expression inside the -name paramater. Or is that impossible. If not I can always pipe it into grep but I would like to do something like this but its not working.
find . -name "*\.(html|php)" -print |
|
|
|
|
|
#5 (permalink) |
|
Da House Nerd
Join Date: Dec 1969
Location: One CPU Lane
Posts: 3,512
|
find . -(i)regex ".+\.(html|php.{0,1})" | xargs
I haven't tried the pattern, you might have to use -E to enable extended regular expression syntax. b.t.w.: for those that feel very lost when reading this, don't worry -- it's just something you'll never be able to do with any GUI.
__________________
Linux virusscanner detected a virus: Windows 95 ... delete [Y/n] y ~ ~ :wq |
|
|
|
|
|
#6 (permalink) | |
|
PCTT Administrator
Join Date: Mar 2003
Location: Las Vegas
Posts: 3,735
|
Quote:
Good because i have no idea what any of that means! Usually when i see that many symbols together they mean someone is cussing! |
|
|
|
|
|
|
#7 (permalink) | |
|
Registered User
Join Date: Sep 2004
Posts: 35
|
Quote:
this worked fine -> -iregex '.*\.\(html\|php\)' |
|
|
|
|
|
|
#8 (permalink) |
|
Da House Nerd
Join Date: Dec 1969
Location: One CPU Lane
Posts: 3,512
|
great
![]() can you post up the final complete command to make the tar here, just for reference? (and to make others possibly even more lost ;-) ) b.t.w.: why do you write ".*\.(html|php)" ? Do you have files named .html or .php that you want to be included?
__________________
Linux virusscanner detected a virus: Windows 95 ... delete [Y/n] y ~ ~ :wq |
|
|
|
|
|
#9 (permalink) |
|
Registered User
Join Date: Sep 2004
Posts: 35
|
About my files being .html or .php. I see where you're going. But since I can't figure out a way to enable "extended regular expression" I was unable to do a +*
I could always substitute a ..* for a +* but that still wouldn't achieve what you want because the results from the find return the relative or absolute paths. So I tried doing something like this [^/] .* but for some reason that doesn't match anything. Oh well, in the meantime this works nearly perfect. Code:
tar -cvjf backup.tar.bz2 `find . -iregex "..*\.\(html\|php\)"` PS: Cool Linux Reference Site/Book Last edited by section31; 12-05-2004 at 05:41 PM. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|