LinuxQuestions.org
Visit Jeremy's Blog.
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 11-23-2008, 12:02 AM   #1
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Rep: Reputation: 38
How do you add files to a .bz2 archived file?


Hi
Actually I have two questions:
1. How do I add files to a .bz2 archived file?

2. How do I archive several different files or directories into one .bz2 file.
 
Old 11-23-2008, 12:22 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
IIRC, you can't ( ie -r won't work with compression). You can specify multiple directories/files on the command line though, so

tar cjf outfile.tar.bz2 /home/user1 /home/user2

If you really want to add files, you would need to untar, add files, retar.
 
Old 11-23-2008, 08:54 AM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
bzip2 and gzip can only compress single files.

If you want to compress many files you first need to join them using another tool. Usually tar is used for that, since it has support for bzip2 (-j) and gzip (-z) integrated. But any other tool that's capable of joining files (and split them when required) will work as well.
 
Old 11-23-2008, 01:06 PM   #4
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Original Poster
Rep: Reputation: 38
There is the -A --concatenate attribute for the tar command but I am not sure exactly what is it for and how to use it. I thought this command was to add additional files.
 
Old 11-23-2008, 01:26 PM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
I think that's i the same category as -r. Do some searching online, but I'm pretty sure I hit the same wall a long time ago.
 
Old 11-23-2008, 03:15 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by okos View Post
There is the -A --concatenate attribute for the tar command but I am not sure exactly what is it for and how to use it. I thought this command was to add additional files.
The GNU tar manual explains it all. --concatenate is meant to join two archives, whereas --append is to add individual files to an existing archive.
 
Old 11-23-2008, 03:51 PM   #7
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Good link colucix.

The restriction I was referring to is here http://www.gnu.org/software/tar/manual/tar.html#SEC127

Quote:
Notice also, that there are several restrictions on operations on compressed archives. First of all, compressed archives cannot be modified, i.e., you cannot update (‘--update’ (‘-u’)) them or delete (‘--delete’) members from them or add (‘--append’ (‘-r’)) members to them. Likewise, you cannot append another tar archive to a compressed archive using ‘--concatenate’ (‘-A’)). Secondly, multi-volume archives cannot be compressed.
 
Old 11-24-2008, 06:55 PM   #8
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Original Poster
Rep: Reputation: 38
Thanks guys
I copied the desired files into a separate directory
tarred it to a bz2 file and then deleted the separate directory

I guess that is the long way around :-[

Last edited by okos; 11-24-2008 at 06:58 PM.
 
  


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
Piping tar bzcat to add a file to a tar.bz2 archive DaveQB Linux - Software 0 06-02-2008 08:28 PM
Can logrotate set limits on archived file size? 0xdefec8 Linux - Server 1 04-05-2008 08:22 PM
silly question, maybe, about archived files permissions sl4ckw4re Slackware 2 08-23-2006 09:28 AM
'Read-only file system' when untar a tar.bz2 file yinglcs Linux - General 1 02-18-2006 09:12 PM
How can konqueror view html files in .gz & .bz2 files directly? ailinzhe Linux - Software 5 05-24-2004 08:36 AM

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

All times are GMT -5. The time now is 11:42 AM.

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