Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how can I exclude file in tar file

242 views
Skip to first unread message

Kenneth

unread,
Aug 10, 2003, 10:36:39 AM8/10/03
to
I want to tar up the whole filesystem but want to exclude some directories.
I have try the --exlcude qualifier, but it just don't work in AIX 4.3.3
ML10, I then check the man page and it didn't mention how I can do it.

Any help?


DT

unread,
Aug 10, 2003, 11:23:26 AM8/10/03
to
man backup

- DT

"Kenneth" <ken...@cde.com> wrote in message
news:bh5l64$no...@rain.i-cable.com...

Kenneth

unread,
Aug 12, 2003, 8:13:14 PM8/12/03
to
So the tar command cannot do it AIX? I remember it can be done in Linux and
HP True 64 Unix.

"DT" <o...@sinaman.com> 在郵件 news:bh5o2v$hb...@imsp212.netvigator.com 中撰寫
...

Nenad

unread,
Aug 13, 2003, 2:29:03 AM8/13/03
to
"Kenneth" <ken...@cde.com> wrote in message
news:bh5l64$no...@rain.i-cable.com...
You can always install gnu tar (see at the bull archive). It
supports --exclude.


Ben Jackson

unread,
Aug 13, 2003, 5:20:49 AM8/13/03
to
Or just do :
# tar cvf tarfile.tar !{filetoexclude}

Ben

Dwivian

unread,
Aug 13, 2003, 10:41:35 AM8/13/03
to
ben.j...@aah.co.uk (Ben Jackson) wrote in message news:<d06d98e2.03081...@posting.google.com>...

> Or just do :
> # tar cvf tarfile.tar !{filetoexclude}
>
> Ben

tar: !test.exclude.file: A file or directory in the path name does not
exist.

Why did you think that would work? You must be using some version of
tar that I don't have...

-dwiv (CATE/AIX)

Chris

unread,
Aug 13, 2003, 5:29:31 PM8/13/03
to
dwi...@earthlink.net (Dwivian) wrote in message news:<b5cff289.03081...@posting.google.com>...

I'm guessing you'll just have to do a find and pipe it to a grep -v,
then pipe that to tar -cvf -

Chris

Villy Kruse

unread,
Aug 14, 2003, 4:00:40 AM8/14/03
to
On 13 Aug 2003 14:29:31 -0700,
Chris <chr...@po.wr.com> wrote:


Stop guessing and RTFM. Pay attention to that AIX version of tar supports
the -L option so:

- Write a file containing the list of files to backup
- Run the AIX tar thus:

tar -c -v -f tarfile.tar -L filelistfile

GNU tar has similar options but with a different name so again: RTFM, this
time the manual for GNU tar.


Villy

Ben Jackson

unread,
Aug 15, 2003, 10:25:22 AM8/15/03
to
dwi...@earthlink.net (Dwivian) wrote in message news:<b5cff289.03081...@posting.google.com>...

Strangely enough I didn't just sit and think it would work, I KNOW it works
as I use it every day on both Solaris and AIX. See below :

# tar cvf tarfile.tar !(file1)
a file2 0K
# tar tvf tarfile.tar
tar: blocksize = 3
-rw-r--r-- 0/1 0 Aug 15 15:20 2003 file2

Ben

Hans-Joachim Ehlers

unread,
Aug 15, 2003, 11:58:34 AM8/15/03
to
"Ben Jackson" <ben.j...@aah.co.uk> schrieb im Newsbeitrag
news:d06d98e2.03081...@posting.google.com...

Its a shell expansion and NOT a tar option.
So !(a) will be expanded by the shell and then passed to tar. I do not know
if every shell support the "!(FILE)" expansion

Example
(0)ffzn0xf3:/tmp/x 372$ set -x

(0)ffzn0xf3:/tmp/x 372$ ls
+ ls
a b c d

ffzn0xf3:/tmp/x 371$ echo !(a)
+ echo b c d
b c d

HTH
Hajo
CATE AIX/RS6000


Dwivian

unread,
Aug 18, 2003, 9:59:43 AM8/18/03
to
"Hans-Joachim Ehlers" <ser...@metamodul.com> wrote in message news:<bhiukk$ga...@news-1.bank.dresdner.net>...

> Its a shell expansion and NOT a tar option.

Ah! That makes more sense... and, the original example used curly
braces, so I didn't catch on.

That works in KSH.

> So !(a) will be expanded by the shell and then passed to tar. I do not know
> if every shell support the "!(FILE)" expansion
>
> Example
> (0)ffzn0xf3:/tmp/x 372$ set -x
>
> (0)ffzn0xf3:/tmp/x 372$ ls
> + ls
> a b c d
>
> ffzn0xf3:/tmp/x 371$ echo !(a)
> + echo b c d
> b c d

Yup...test works just as described, using KSH on AIX.

Thanks for clearing that up! There are significant differences with {
and (, you see... :)

-dwiv (CATE/AIX)

K. B.

unread,
Aug 19, 2003, 3:42:05 PM8/19/03
to
ben.j...@aah.co.uk (Ben Jackson) wrote in message news:<d06d98e2.03081...@posting.google.com>...
> dwi...@earthlink.net (Dwivian) wrote in message news:<b5cff289.03081...@posting.google.com>...
> > ben.j...@aah.co.uk (Ben Jackson) wrote in message news:<d06d98e2.03081...@posting.google.com>...
> > > Or just do :
> > > # tar cvf tarfile.tar !{filetoexclude}
> > >
> > > Ben
> >
> > tar: !test.exclude.file: A file or directory in the path name does not
> > exist.
> >
> > Why did you think that would work? You must be using some version of
> > tar that I don't have...
> >
> > -dwiv (CATE/AIX)
>
> Strangely enough I didn't just sit and think it would work, I KNOW it works
> as I use it every day on both Solaris and AIX. See below :
>
> # tar cvf tarfile.tar !(file1)
> a file2 0K
> # tar tvf tarfile.tar
> tar: blocksize = 3
> -rw-r--r-- 0/1 0 Aug 15 15:20 2003 file2
>
> Ben


Wow about a month ago I was looking for this very option. Thank you
for sharing the knowledge. I am curious however, will this work for
directories as well? And, what if you wanted to exclude multiple
files is there a particular syntax?

KB

0 new messages