How to create a compressed tar in sun solaris

tar

I am logged into Sun Solaris OS. I want to create and extract a compressed tar file. I tried this normal UNIX command:

tar -cvzf file.tar.gz directory1

It is failing to execute in Sun OS with following error

bash-3.2$ tar -cvzf file.tar.tz directory1
tar: z: unknown function modifier
Usage: tar {c|r|t|u|x}[BDeEFhilmnopPqTvw@[0-7]][bfk][X...] [blocksize] [tarfile] [size] [exclude-file...] {file | -I include-file | -C directory file}...

Best Answer

To avoid creation of temporary intermediate file you can use this command

tar cvf - directory1|gzip -c >file.tar.gz
Related Question