How do I compress a directory and its contents in ksh
on AIX
for a file I do compress filename
How do I compress a directory and its contents in ksh
on AIX
for a file I do compress filename
tar cjf <your-name-in-specific-path> <your-directory-path>
c: Create
j: Use bzip2 for compression
f: Save it to given file name
NOTE: If your tar version doesn't have these options you can follow the below instruction:
tar cf <your-name-in-specific-path> <your-directory-path>
gzip <your-name-in-specific-path>
NOTE: You can compress your file with other tools like bzip2
, xz
and so on.
A directory cannot be compressed, because a directory is not a plain file. It is a pointer to a container of a set of files.
You can tar
a directory and its contents into a single file and compress that file. Or you can cd
into the directory and compress each individual file.
Tar in AIX by default does not support compression. You will need to incorporate with gzip command to have it tar and compress at the same time.
$ tar cvf test.tar test # pure tar only
$ tar cvf - test | gzip > test.tar.gz # tar and compress together
To uncompress and untar as well :
$ gunzip -c test.tar.gz | tar tvf - # list compress files
$ gunzip -c test.tar.gz | tar xvf - # decompress files