1834343 Members
2273 Online
110066 Solutions
New Discussion

Compress files problem

 
SOLVED
Go to solution
ust3
Regular Advisor

Compress files problem

I have a path , there are many many files in it ( over 100K files ) , I want to run tar -zcvf to compress it , when I gzip it , it pop "/usr/bin/gzip: Argument list too long" , when I use the script "find . -exec /bin/tar -zcvf file.tgz {} \; , the compress process will be start but have stopped when compressed a few files , can advise how can I do the compress process ? thx
7 REPLIES 7
Dennis Handly
Acclaimed Contributor
Solution

Re: Compress files problem

-z isn't available in HP-UX. You'll have to pipe the tar output to gzip:
tar -cvf - . | gzip > file.tgz

(If you want everything under ".", why use find(1)? tar(1) does that just fine.)

Dennis Handly
Acclaimed Contributor

Re: Compress files problem

Oops, slight typo:
tar -cvf - . | gzip > file.tgz
Steven Schweda
Honored Contributor

Re: Compress files problem

> -z isn't available in HP-UX.

Well, not with the "tar" supplied with HP-UX.
GNU "tar" runs on HP-UX, and it offers "-z".

http://www.gnu.org/software/tar/

> [...] when I gzip it [...]

Using what command?

It's not clear what you want, but the
suggestion of:

tar -cvf - . | gzip file.tgz

is probably what you should want. And it's
essentially what (GNU) "tar -cfvz file.tgz ."
does.

This:

find . -exec /bin/tar -zcvf file.tgz {} \;

looks to me as it it will run "tar" for each
file, which has to be a lame way to do the
job.
Amit Parui
Valued Contributor

Re: Compress files problem

U can simply do - tar -cvf or go to the folder and do - tar -cvf *.* in the particular path.
Then gzip the tar file - gzip xyz.tar or

tar -cvf *.* | gzip *.tar

Hope this helps !!!
If Life gives u a ROCK, its upto u to build a BRIDGE or a WALL !!!
Dennis Handly
Acclaimed Contributor

Re: Compress files problem

>Hunter_29: go to the folder

(There are no folders on Unix. ;-)

>tar -cvf *.* in the particular path.

*.* isn't a good pattern for tar, it misses names without ".".

>Then gzip the tar file - gzip xyz.tar

Yes.

>tar -cvf *.* | gzip *.tar

You forgot the file or "-" and the pipe would need more plumbing/fiddling.
ust3
Regular Advisor

Re: Compress files problem

thx replies,

I use the command tar -cvf - . | gzip > file.tgz , it works fine , I would like to ask one more question , what is the function of - ( the second one ) in this command ? I tried that if not omit it , it is not work . thx
Dennis Handly
Acclaimed Contributor

Re: Compress files problem

>what is the function of - in this command? I tried that if not omit it, it is not work.

-f takes a file name. So you have to have something there. "-" is a convention in UNIX commands to use stdout or stdin for that file.