[fedora] dd

suvayu ali fatkasuvayu+linux at gmail.com
Sun Sep 4 15:17:51 UTC 2011


Hi Xinyou,

On Sun, Sep 4, 2011 at 4:53 PM, xinyou yan <yxy.716 at gmail.com> wrote:
>> I am not sure what the problem is.
>> The following works for me:
>> tar cf archive.tar first
>> tar -rf archive.tar second
> Yes it can , But tar czf tar rzf can't work
> Second :
>
> if I use
> gzip -c file1 >>  yyy.test
> How can I unpress yyy.test to file1 as file1
> I test like it
> gzip -c test1 > 1.test
> We can use
>
> gunzip -c 1.test >test1
>
> to achieve my answer .
> However :
> gzip -c test1 >> 1.test
> gzip -c test2 >> 1.test
>
> I just gunzip -c 1.test > test1 (the size of test1 now is  the sum
> test1 and test2 before)
>
> How can i use gunzip  to separate the  two file ?
> I wonder  >>  can remember there are two file ?

I think you are mixing up compression and archiving as similar things.
They should be done in a particular order:

1. to create: archive -> compress
2. to modify: decompress -> modify archive -> compress
3. restore:   decompress -> unarchive

Now (1) and (3) can be done in one step using the -z or -j option to
tar, however for (2) you need to decompress first using `gunzip' or `gzip
-d' before you can use `tar -r -f <archivefile.tar>' to modify it.

To give you an example:

$ tar -czf backup.tar.gz *.org # backup all .org files
$ tar -tzf backup.tar.gz # test if it worked
analysis.org
coding.org
fiddle.org
languages.org
meetings.org
notes.org
org-help.org
$ gunzip backup.tar.gz # decompress the compressed archive
$ tar -rf backup.tar *.org_archive # add .org_archive files
$ gzip backup.tar # compress modified archive
$ tar -tzf backup.tar.gz # test again
analysis.org
coding.org
fiddle.org
languages.org
meetings.org
notes.org
org-help.org
analysis.org_archive
meetings.org_archive
notes.org_archive
$ tar -xzf backup.tar.gz '*.org' # restore only .org files
$ ls
analysis.org  backup.tar.gz  coding.org  fiddle.org  languages.org
meetings.org  notes.org  org-help.org

In the future I would recommend try going through the manual page for
tar and gzip carefully (`man tar' and `man gzip').

I hope this helps.

-- 
Suvayu

Open source is the future. It sets us free.


More information about the users mailing list