- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Exclude tar a directory
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 04:10 PM
тАО10-11-2005 04:10 PM
Exclude tar a directory
ll
drw-r--r-- 1 root root 4096 Oct 12 11:58 b
drw-r--r-- 1 root root 4096 Oct 12 10:54 c
drwxr-xr-x 2 root root 4096 Oct 12 11:57 d
drw-r--r-- 1 root root 4096 Oct 12 10:54 d
eg . I want to tar all files under the above directory but exclude the sub-directory "c" ( not exclude file ) , could advise how to do it ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 06:27 PM
тАО10-11-2005 06:27 PM
Re: Exclude tar a directory
u can use the -x option copy file or all files from a directory
regrads gga
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 06:35 PM
тАО10-11-2005 06:35 PM
Re: Exclude tar a directory
`--separate-dirs'
Report the size of each directory separately, not including the
sizes of subdirectories.
`-x'
`--one-file-system'
Skip directories that are on different filesystems from the one
that the argument being processed is on.
`--exclude=PAT'
When recursing, skip subdirectories or files matching PAT. For
example, `du --exclude='*.o'' excludes files whose names end in
`.o'.
`-X FILE'
`--exclude-from=FILE'
Like `--exclude', except take the patterns to exclude from FILE,
one per line. If FILE is `-', take the patterns from standard
input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 07:25 PM
тАО10-11-2005 07:25 PM
Re: Exclude tar a directory
from your suggestions , it seems no parameter can exclude the directory to tar , isn't it ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 09:56 PM
тАО10-11-2005 09:56 PM
Re: Exclude tar a directory
# tar cvf /tmp/tarfile $(ll -tr | awk '$1~/^d/ && $NF!="c" {print $NF}')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 10:00 PM
тАО10-11-2005 10:00 PM
Re: Exclude tar a directory
find ... | pax -wf archive_file
You can customize the find/pattern command to only list the files you want?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2005 01:45 AM
тАО10-13-2005 01:45 AM
Re: Exclude tar a directory
you can use KSH filename generation to let the shell do this for you - just have no HPUX at hand to check, whether the posix shell has this capability as well:
(in ksh)
!(name) will match anything but 'name',
so
tar cf xxx.tar !(c)
will not archive 'c'.
mfG nik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2005 02:34 AM
тАО10-13-2005 02:34 AM
Re: Exclude tar a directory
Let's assume that you're dir name that you're excluding isn't "c" , but "mydir":
ll | awk '{print $NF}' | grep -v mydir > useme
verify the list of directories and files:
cat useme
create tarball with just those files:
tar -cvf my.tar `cat useme`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2005 03:06 AM
тАО10-13-2005 03:06 AM
Re: Exclude tar a directory
remember, that a inverse-match (via grep -v mydir) has the bad effect of eliminating entries like
savemydir
as well.
More, the filename generation pattern can easily extended to more than one exception entry like
!(c|d)
which leads to multiple
grep -v one | grep -v other ..
in your solution.
Possible would be
ls | awk '{$1 ~ "mydir";next};{print}' to get the list.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2005 03:08 AM
тАО10-13-2005 03:08 AM
Re: Exclude tar a directory
I wanted to state
ls | awk '{$1 == "mydir";next};{print}' to get the list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2005 03:16 AM
тАО10-13-2005 03:16 AM
Re: Exclude tar a directory
Taking your comments along with what I wrote earlier:
Put the directory names into a file called useme.
Let's assume that you're dir name that you're excluding isn't "c" , but "mydir":
ls | awk '{$1 == "mydir";next};{print}' > useme
verify the list of directories and files:
cat useme
create tarball with just those files:
tar -cvf my.tar `cat useme`