Compress multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compress multiple files
# 1  
Old 04-27-2007
Compress multiple files

Hi Friends,

Can anyone help me out with compressing multiple files.
I have multiple files in directory , I have to compress these into a single file,
I tried using
gzip -r outfile.gz file1 file2 file3.

It is not working

Thanks in advance for your help
S Smilie
# 2  
Old 04-27-2007
Code:
gzip -c file1 file2 > foo.gz

however this will compress better:

Code:
cat file1 file2 file3 | gzip -c > foo.gz

# 3  
Old 04-27-2007
[QUOTE=reborg]
Code:
gzip -c file1 file2 > foo.gz

Thank you very much for your quick reply.
I have tried this command
here it is compressing the two files in to a single file,
If we unzip this file it is chowing as a single file ,
instead can this be upzipped in to two files.
# 4  
Old 04-27-2007
then, for standard unix utilities, you must first "tar" the files into a single file, then compress.

Check the man pages on tar and gzip. You will want to use the "-c" parameter, if you want to do this as a single step.

Otherwise, get pkzip for your machine/version of unix, and use it.
# 5  
Old 04-29-2007
Generally, I think its:

Create a tar file: tar cvf <tar.filename> <files.to.tar.up>
Extract a tar file: tar xvf <tar.filename>
Check the contents of a tar file: tar tvf <tar.filename>
# 6  
Old 04-29-2007
To use tar and gzip/compress together, you will have to use the pipe '|'.

Like this:
To compress:
Code:
tar -cf - list_of_file_names | gzip > output_file.tar.gz

To uncompress:
Code:
gzip -dc output_file.tar.gz | tar -xf -

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Compress multiple gzip files

Good afternoon friends. I wanted to make a query, how to compress several files and leave them all in 1, for example flat text files: filename_1.csv filename_2.csv filename_3.csv expected result filename_end.gzip = (filename_1.csv filename_2.csv filename_3.csv) please (2 Replies)
Discussion started by: tricampeon81
2 Replies

2. Shell Programming and Scripting

Compress Files in Multiple Directories

I would like to compress the files in multiple directories. For some reason, it only compress the first directory (/Sanbox/logs1) but not the rest of the other directories ("/Sanbox/logs2" "/Sanbox/logs3" "/Sanbox/logs4" ). Any help would be appreciated. Here's my code: #!/bin/bash... (1 Reply)
Discussion started by: Loc
1 Replies

3. Shell Programming and Scripting

Compress files as per timestamp in multiple subdirectories

I'd really appreciate if anyone could assist me with this code A directory with multiple subdirectories has multiple files which are timestamp'ed. We need to - compress files as per timestamp - save compressed file/s in the respective folder - delete the source files ============... (2 Replies)
Discussion started by: sreewin7
2 Replies

4. 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

5. UNIX for Dummies Questions & Answers

How to compress files without extension

Could someone please help? I'm trying to compress all the files in a directory without extension. I know for typical files with extension, the command is something like: tar -zcvf file.tar.gz *.doc What is the command for files without extension? Thanks. (4 Replies)
Discussion started by: AChan1118
4 Replies

6. UNIX for Dummies Questions & Answers

find new files and compress them

Hi! First off I'd like to stress that I'm a true dummy :) I have a website with SSH access and since it has user generated content I want to backup my website every day end send it through FTP to a different server. I got it working for my mysql database, so the only thing remaining are the... (2 Replies)
Discussion started by: Mark Wegener
2 Replies

7. UNIX for Dummies Questions & Answers

Compress multiple files at one go

I want to compress all the files which are three years older ..I have thousands of files... 1) This doesnt work find ./ -type f -mtime +1176 -print | xargs -n1 -i tar -cvf {} Errror tar: Missing filenames Probably because of - find ./ -type f -mtime -1 -print returns - " ./temp.txt"... (6 Replies)
Discussion started by: kedar.mehta
6 Replies

8. Shell Programming and Scripting

compress files

Could someone give me an idea how to compress all files from a given directory that are not of type .z (compressed). Please help. (2 Replies)
Discussion started by: lesstjm
2 Replies

9. UNIX for Dummies Questions & Answers

Compress files

Hi All, I would like to archive some of the scripts below(USFINUM042006_01.CSV USFINUM042006_02.CSV and USFINUM042006_03.CSV )and also use a wildcard e.g. <command> USFINUM*.CSV. Also there are a lot of similar files but I want only the three latest files to be compressed. Which is the best... (3 Replies)
Discussion started by: indira
3 Replies

10. Shell Programming and Scripting

Compress all INACTIVE Files

Hi gurus, I have a batch job running daily night automatically. The job produces file with extension '.0' like a.0, b.0 etc. Now due to file space constraints, most of the time, the job fails with insufficient disk space and then we have to manually start the job again and keep running the... (1 Reply)
Discussion started by: super_duper_guy
1 Replies
Login or Register to Ask a Question