LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Adding Multiple Files In A Single Gz File (https://www.linuxquestions.org/questions/linux-newbie-8/adding-multiple-files-in-a-single-gz-file-478747/)

onacorpuscle 08-30-2006 07:28 AM

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!

oneandoneis2 08-30-2006 07:43 AM

Use tar to create a Gzipped or Bzipped archive of multiple files

onacorpuscle 08-31-2006 02:28 AM

"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!

:rolleyes:

theYinYeti 08-31-2006 03:18 AM

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.


All times are GMT -5. The time now is 10:06 PM.