1834163 Members
2518 Online
110064 Solutions
New Discussion

zgip a list of files

 
Thi Vu
Frequent Advisor

zgip a list of files

I have a list of files for a whole month that I want to gzip, instead of going to gzip each individual file I thought I can do this at the command line:

ll | grep $Month | gzip -vf *

but I keep getting the complaint "/usr/../gzip: the parameter list is too long" is there a better way of doing this than doing the manual command one file at a time. Thank for your assistant.
4 REPLIES 4
Madhu Sudhan_1
Respected Contributor

Re: zgip a list of files

Thi Vu :
Use it this way.
To compress
# tar cvf - *.c | /usr/contrib/bin/gzip -c >allc.tar.gz
To uncompress
# /usr/contrib/bin/gzip -d allc.tar.gz
#tar xvf allc.tar

Should server your purposed.

Enjoy !
......Madhu
Think Positive

Re: zgip a list of files

Hi Thi Vu!

Try this:

ll |grep "$Month"|awk '{print $9}'|xargs gunzip -vf

Bye

CGRC

Re: zgip a list of files

And

to compress:

ll |grep "$Month"|awk '{print $9}'|xargs gzip -vf

Good Day

CGRC
James R. Ferguson
Acclaimed Contributor

Re: zgip a list of files

Hi:

Using 'xargs' is a good way to resolve your problem as already indicated.

Modifying and regenerating your kernel (in 10.20) with 'large_ncargs_enabled=1' is another way to avoid some of these problems.

From document #A5390842:

The 'arg list too long' error occurs when you exceed the maximum length of arguments that can be passed to a command.

The default is 20478 bytes, but you can increase this value to 2048000 by setting the kernel parameter 'large_ncargs_enabled = 1' (default is 0).

You can execute 'getconf ARG_MAX' to find out if 'large_ncargs_enabled' is set to 1 or 0. For example:

$ getconf ARG_MAX
20478

If you receive 20478 when you execute the command, recompile the kernel with 'large_ncargs_enabled=1' to resolve the error.

Note that for HP-UX 11.0 systems, the limit is set to the larger value by default, and the large_ncargs_enabled kernel tunable is not needed.

Note that patch:

PHKL_16410
s800 10.20 LVM/UFS/NDDB/flkmgr/VxFS,DMAPI/PCI/SCSI/MO/dump

enables this kernel parameter, so you may need to install it if you do not already have it or a superseding patch installed already.

...JRF...