HP-UNIX How to zip/compress files in a folder?


 
Thread Tools Search this Thread
Operating Systems HP-UX HP-UNIX How to zip/compress files in a folder?
# 1  
Old 09-09-2015
HP HP-UNIX How to zip/compress files in a folder?

Environment: HP-Unix Operating System B.11.31 U ia64

I have a folder with around 2000 files. There are some files which sizes are more than 8 GB. I need to compress all the files in the folder into a single file, so that I can transfer the file.

I tried with tar command, but the tar command is failing if the filesize is more than 8 GB.

Please advise me the efficient way of compressing / zipping all these 2000 files in a folder.
# 2  
Old 09-09-2015
TAR does not compress. It creates archives.

You will need to use gzip first on all files, then pax to create a big archive, since on HPUX tar will not support READ of archives greater then 8GB (but i think it will create one tho Smilie )

Alternative to above is to install gnu tar on HPUX machine and use that directly with compression (-z switch).

Hope that helps.

Regards
Peasant.
# 3  
Old 09-09-2015
It is usually better to first tar then gzip:
Example:
Code:
tar cf - /path/to/folder | gzip -c > folder.tar.gz

Or create one on a remote system
Code:
tar cf - /path/to/folder | gzip -c | ssh remote_system "cat > /destination/folder.tar.gz"

It is also possible to store a relative path (easier to re-locate during extraction)
Code:
cd /path/to && tar cf - folder | ...

or
Code:
cd /path/to/folder && tar cf - . | ...


Last edited by MadeInGermany; 09-09-2015 at 09:33 AM..
# 4  
Old 09-09-2015
HP

Quote:
Originally Posted by MadeInGermany
It is usually better to first tar then gzip:
Example:
Code:
tar cf - /path/to/folder | gzip -c > folder.tar.gz

Or create one on a remote system
Code:
tar cf - /path/to/folder | gzip -c | ssh remote_system "cat > /destination/folder.tar.gz"

It is also possible to store a relative path (easier to re-locate during extraction)
Code:
cd /path/to && tar cf - folder | ...

or
Code:
cd /path/to/folder && tar cf - . | ...

Thanks for the reply.

But I can not use
Code:
 tar

as it skips the files which are greater than 8 GB.

Please suggest other than tar.
# 5  
Old 09-09-2015
Maybe cpio does not have this limitation?
Code:
cd /path/to/folder && find . -print | cpio -o | gzip -c > folder.cpio.gz

Or to remote system
Code:
cd /path/to/folder && find . -print | cpio -o | gzip -c | ssh remote_system "cat > /destination/folder.cpio.gz"

To unpack a .cpio.gz file in the current directory, run
Code:
gunzip -c /destination/folder.cpio.gz | cpio -idm

---------- Post updated at 09:33 AM ---------- Previous update was at 09:18 AM ----------

Another alternative, with pax that is compatible with tar:
Code:
cd /path/to/folder && pax -wf - . | gzip -c > folder.tar.gz

To a remote system
Code:
cd /path/to/folder && pax -wf - . | gzip -c | ssh remote_system "cat > folder.tar.gz"

# 6  
Old 01-20-2016
Java

we can't use cpio command, because it limited to 2GB as man page said:

Because of industry standards and interoperability goals, cpio does
not support the archival of files larger than 2 GB or files that have
user/group IDs greater than 60 K. Files with user/group IDs greater
than 60 K are archived and restored under the user/group ID of the
current process.
This User Gave Thanks to Naheed Kamal For This Post:
# 7  
Old 01-20-2016
If you have multiple files which are in same format say csv, then you can navigate into the directory and issue the below command
Code:
zip -r zip_file_name *.csv

This will zip all csv files into a zip file by name zip_file_name
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

2. Shell Programming and Scripting

Checking for zip / compress to use - tips for improvement?

Hi, Just want to know if anyone can suggest if there is a "better" way of coding the if-then-else block below: ZIP="" if ] ; then ZIP=`which compress` echo "ZIP program to use = ${ZIP}" elif ] ; then ZIP=`which gzip` echo "ZIP program to use = ${ZIP}" else echo... (2 Replies)
Discussion started by: newbie_01
2 Replies

3. Shell Programming and Scripting

Need to Zip files three years old or longer but leave folder structure intact

Hi all, Hello everyone, my first post here :). I tried to search the forum but I didn't find exactly what I was looking for... I need to zip/tar files across entire filesystem which are more 3+ years old but leave folder structure intact. If the script locates tar/zip files they are more... (1 Reply)
Discussion started by: sashruby
1 Replies

4. Shell Programming and Scripting

compress folder

hi guys, i've read that i need to use tar first before gzip. just wanted to be sure if there's no way of compressing a folder with all its files like winzip in windows? using tar then gzip in unix, i will need to open 2 zip files in order to get the files unlike winzip. i'd appreciate any... (2 Replies)
Discussion started by: adshocker
2 Replies

5. UNIX for Advanced & Expert Users

UNIX: Command to compress folder and all files into a tar

I am trying to grab a folder and all the folders and files underneath it and send it from one computer to another. I basically want to compress the whole folder into a tar, tgz, or zip file so that it can be sent as one file. is there a command to compress a folder and all its contents into a tar... (7 Replies)
Discussion started by: kane4355
7 Replies

6. UNIX for Dummies Questions & Answers

Issue: Compress in unix server and FTP to windows and open the compress file using Winzip

Hi All ! We have to compress a big data file in unix server and transfer it to windows and uncompress it using winzip in windows. I have used the utility ZIP like the below. zip -e <newfilename> df2_test_extract.dat but when I compress files greater than 4 gb using zip utility, it... (4 Replies)
Discussion started by: sakthifire
4 Replies

7. UNIX for Dummies Questions & Answers

Zip command (zip folder doesn't include a folder of the same name)

Hi guys, I have a question about the zip command. Right now I have a directory with some files and folders on it that I want to compress. When I run the zip command: zip foo -r I am getting a foo.zip file that once I unzip it contains a foo folder. I want to create the foo.zip, but that... (1 Reply)
Discussion started by: elioncho
1 Replies

8. Windows & DOS: Issues & Discussions

How can I upload a zip folder on a unix path from my windows folder?

Hello, I am an amature at UNIX commands and functionality. Please could you all assist me by replying to my below mentioned querry : How can I upload a zip folder on a unix path from my windows folder? Thanks guys Cheers (2 Replies)
Discussion started by: ajit.yadav83
2 Replies

9. UNIX Desktop Questions & Answers

file zip,rar,tar,compress,uncompress,unzip,unrar

i want know how to compress and uncompress file using unix, compress uncompress,zip,unzip,rar,unrar,how its work and more about this.:confused: (1 Reply)
Discussion started by: ismael xavier
1 Replies

10. UNIX for Advanced & Expert Users

Compress and copy a Folder

hi Buddies , How can i Compress and move a folder through UNIX completely to windows 2000 through FTP. (1 Reply)
Discussion started by: scorpiyanz
1 Replies
Login or Register to Ask a Question