Welcome to WebmasterWorld Guest from 54.227.110.209

Forum Moderators: bakedjake

Message Too Old, No Replies

Tar all files and exclude a folder?

How to tar all files and folders in current folder except one folder?

     

sunroof

10:53 pm on Mar 11, 2008 (gmt 0)

5+ Year Member



How to tar all files, folders, subfolders... in current folder except one folder named 'test'?

something like: tar -cf all.tar * + exclude 'test'

Thanks

lammert

12:06 am on Mar 12, 2008 (gmt 0)

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



You first need to allow extended wildcard options, you can then exclude files or directories from the tar command line. I use the following commands to backup everything in /usr/src, except for the sub directories that start with "linux-2.6". You need to experiment a little to see how you have to construct the excluding wildcard options for your situation.

shopt -s extglob
/bin/tar -cf all.tar usr/src/!(linux-2.6*)

OutdoorWebcams

4:43 pm on Mar 12, 2008 (gmt 0)

5+ Year Member



You might also try this:

tar -cf all.tar --exclude test *

 

Featured Threads

Hot Threads This Week

Hot Threads This Month