2

I want to create a GZIP compressed TAR archive containing the contents of /var/log, but excluding /var/log/messages file.

I tried tar -cvf var/log.tar var/log/ -x *.messages*, but got the error message:

tar: You may not specify more  than one `-Acdtrux' or `--test-label' option

Any ideas on how to go about this? I'm pretty confident I can create the archive, just not sure how to exclude the /var/log/messages file.

1 Answer 1

1

The -x flag (short for --extract) tells tar to unpack an archive. The -c flag (short for --create) tells tar to create an archive. You're passing both flags, which is a contradiction. It looks like you probably want to use the --exclude flag instead of the -x flag, e.g.:

tar -cvf var/log.tar var/log --exclude='*.messages*'
1
  • 1
    Thanks! That was a huge help. I ended up doing tar -cvf log.tar /var/log --exclude=/var/log/messages and it worked like a charm. Commented Mar 7, 2019 at 2:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .