LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 10-19-2009, 09:51 PM   #1
SirTristan
Member
 
Registered: Feb 2006
Distribution: GNU/Linux
Posts: 54

Rep: Reputation: 15
gzip but keep the original file, and bzip2 - multiple files to one file?


Is there a way to keep the original files with gzip, like the bzip2 -k or --keep option?

Also, if one is compressing multiple files with bzip2, can one have the output be in a single file? e.g., *.txt to all.bz2.
 
Old 10-19-2009, 10:11 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Probably the best bet for gzip is to use standard redirection, ie
Code:
gzip -c inputfiles >output.gz
If you want to have multiple files in one bzip archive, normally people would use tar.
Code:
tar cjf output.tar.bz2 inputfiles
 
Old 10-20-2009, 12:35 AM   #3
SirTristan
Member
 
Registered: Feb 2006
Distribution: GNU/Linux
Posts: 54

Original Poster
Rep: Reputation: 15
Thanks. So you can't combine multiple files with bzip alone?
 
Old 10-20-2009, 01:27 AM   #4
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
So you can't combine multiple files with bzip alone?
I don't know how. You can redirect multiple files to a single compressed file via stdout, but then you lose all the file information (so it decompresses to a single file).
 
Old 10-20-2009, 03:37 AM   #5
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,475

Rep: Reputation: 87
Have you considered 7zip for compression?

It compresses extremely well (in my experience, often up to 20% better than bzip).

Not sure if it will take multiple files though - what's wrong with tarring and then bzipping / 7zipping the tar file?

We do all our backups (tens of thousands of files) this way - a cronjob which tars a thousand files or more into one .tar file, then 7zips that file, every 24 hours...

Last edited by rylan76; 10-20-2009 at 03:38 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
chapter 6, want to use bzip2 but it fails with bash: bzip2: No such file or directory nomad5000 Linux From Scratch 2 10-12-2009 08:58 PM
how to open gzip file? I have gzip installed mhg Linux - Newbie 3 10-24-2008 02:18 AM
bzip2 and gzip ust Linux - Software 1 02-08-2005 10:26 AM
bzip2 vs.gzip mikeshn Linux - Software 2 09-20-2003 09:30 AM
gzip and leave the original file intact WindozBytes Programming 4 09-04-2002 09:26 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration