LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-30-2006, 07:28 AM   #1
onacorpuscle
LQ Newbie
 
Registered: Mar 2006
Location: Barcelona
Distribution: SUSE LINUX 9.3
Posts: 10

Rep: Reputation: 0
Angry Adding Multiple Files In A Single Gz File


Dear collegues

I'm a problem with multiple compression in a single file. In the past I compressed wiht ZIP command, multiples files into one single file. The command looks like this:

#zip -m -j $copy_path/$pref_file2$date $copy_path/$search_string*$date.$search_string*

Whit the -m flag, can I put several files in the single file spicified by params.
Before the compression, a FTP process runned by crontab transfer them to another path.

Because in this new environtment only gzip is authorised,I attempt to repeat the same whit :


#gzip -r $copy_path/$pref_file2$date $copy_path/$search_string*$date.$search_string*

But don't work, because this command generate one gz file for each file processed.

Thanks!
 
Old 08-30-2006, 07:43 AM   #2
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 48
Use tar to create a Gzipped or Bzipped archive of multiple files
 
Old 08-31-2006, 02:28 AM   #3
onacorpuscle
LQ Newbie
 
Registered: Mar 2006
Location: Barcelona
Distribution: SUSE LINUX 9.3
Posts: 10

Original Poster
Rep: Reputation: 0
"Adding Multiple Files In A Single Gz

Thank's a lot for all!

I solved the problem, with a different approach:

cat | $copy_path"/"$search_string*$date"."$search_string* | gzip > $copy_path"/"$pref_file2$date".gz"

I create only one gz file that contain all the file that matches whit the search criteria...

Is not the same, but works!

One more time Thanks!

 
Old 08-31-2006, 03:18 AM   #4
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
Indeed, this would work (althouth I think you put one too many '|' in this command), but then all your files are actually merged into one! This might be what you want if all files are text files, but I seriously doubt it.

The first thing to understand is a difference in philosophy:
- In Windows, tools often strive to be as complete as possible, to do it all from start to end, and if possible do it well.
- In Linux, tools usually strive to do as little as possible, but do it extremely well, and it is usually the shell's task to combine those small tools to obtain the final result, or sometimes one uses front-ends or wrapper tools.

ZIP is a typical Windows-philosophy tool: you give it files, and it outputs a single compressed file with all inside, all this using a rather nice, but unique, GUI.

In Linux, you have choice to group files, although the most common tool is "tar"; you have choice for compressing this file, and "gzip" and "bzip2" are the most common ones (for your convenience, "tar" is able to use them by itself); lastly, you have choice between the text-mode or numerous more or less complete GUI for all tastes.

The typical text-mode command for creating the equivalent of a ZIP file is:
Code:
tar -cjf archive.tar.bz2 file1 file2 ... fileN
but files to add to the archive can also be read from the result of a command or from a file that contains the names.

Yves.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling multiple .c file using single command in makefile vipulc Linux - General 2 03-18-2006 11:49 PM
How To Merge multiple files into a single PDF ? kkempter Linux - Software 1 10-28-2005 01:02 PM
merge multiple lines of a single file into one line groverrajiv Linux - Newbie 4 05-26-2004 02:38 AM
Copying a single file to multiple directories tgolly Linux - Newbie 3 04-26-2004 03:47 PM
How do I decompress and desarchive multiple .tar.gz files to a single directory? Baldorg Linux - Software 7 11-27-2003 12:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration