Technical article 105449

How can I make a tar archive of compressed files?

OpenServer 5.0.0OpenServer 5.0.2

Written · Last revised

Problem

I have noticed that SCO software is sometimes distributed in a
tar archive format that contains compressed files (even though
the filenames do not have ".Z" suffixes).  When the tar archive
is extracted, the tar utility will automatically use the uncompress
utility to uncompress the files when required.  How do I create
such a tar archive of compressed files?

Solution

Follow these steps:

1. Compress files individually using the compress command. For example:

# compress thisfile
2. Strip the ".Z" extension from the file names.  You may want
   to make use of the expr or basename commands to do this.
   For example:
# mv thisfile.Z `basename thisfile .Z`

3. Create the tar archive using a capital "C" instead of the small "c" function to flag to tar that files are compressed.

# tar Cv .            # here the archive is created on
                      # the default device in /etc/default/tar,
                      # usually the primary floppy drive

The more detailed example below assumes that you want to compress all of the files in the subdirectory structure named "/tmp/myfiles" and copy them to a tar archive on tape:

# cd /tmp/myfiles
# find . -type f -print | xargs compress
# find . -type f -name '*.Z' -print |
>     xargs -i expr '{}' : '\(.*\).Z' |
>     xargs -i mv {}.Z {}
# tar Cv8 .            # assuming that "8" references the
                       # correct device in /etc/default/tar
When the compressed files are subsequently extracted by the
tar utility, they will be automatically uncompressed.

See also

tar(C), compress(C), expr(C), xargs(C)

From the Xinuos technical article database, record 105449. Reproduced with permission. The original is at www.sco.com/ta/105449, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.