LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-18-2006, 01:51 PM   #1
nightrider
Member
 
Registered: Apr 2005
Location: Sao Paulo - Brazil
Distribution: Open Suse 12.1 64
Posts: 166

Rep: Reputation: 15
Curious(at least for me) tar behaviour


Look the snapshot below, please:

======================================================================
[ricardo@localhost ~]$ tar --gzip --create --verbose --file=/home/ricardo/tmp/xxx.tar.gz /home/ricardo/testesfpc/teste.pas /home/ricardo/testesfpc/h.pas --recursion
tar: Removing leading `/' from member names
/home/ricardo/testesfpc/teste.pas
/home/ricardo/testesfpc/h.pas
tar: --recursion: It is not possible stat: File or directory not found
tar: Saída por erro atrasada pelos erros anteriores
[ricardo@localhost ~]$
=====================================================================

Why I receive an error in the --recursion?

I guarantee that there are sub directories in the /home/ricardo/testesfpc.

I try to put --recursion before the --file parameter. The error disappear but no recursion takes place

All files and directories of testesfpc has read permission in the three diectory levels...

The GNU manual says that --recursion is the default but the recursion never occurs.

tar (GNU tar) 1.15.1

It's driven my crazy.

Greetings from Sao Paulo - Brazil

Ricardo
 
Old 12-18-2006, 04:06 PM   #2
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 23
Posts: 72

Rep: Reputation: 19
First of all tar does recurse through files and directories as the default. This command should work:

tar --gzip --create --verbose --file=/home/ricardo/tmp/xxx.tar.gz /home/ricardo/testesfpc/teste.pas /home/ricardo/testesfpc/h.pas

Remove the --recurse from after the files names. Tar is treating "--recurse" as a file name and cannot find it. Are the names you specified (/home/ricardo/testesfpc/teste.pas /home/ricardo/testesfpc/h.pas) directories or files?

If they are:
* the 2 files will placed into the archive.
* directories it will put all files and sub-directories into the archive

Dan
 
Old 12-19-2006, 08:19 AM   #3
nightrider
Member
 
Registered: Apr 2005
Location: Sao Paulo - Brazil
Distribution: Open Suse 12.1 64
Posts: 166

Original Poster
Rep: Reputation: 15
First of all:

I read about the recurse default in the GNU tar manual that I downloaded from the Free Software Foundation site showed below:

http://www.gnu.org/software/tar/manual/

In the page 102, item 6.9 "Descending into Directories" is written:

"Usually, tar will recursively explore all directories".

May I suppose that --recursion is the default, or not?

Second of all:

You forgot to expose how would be the command line for include the two files listed and recurse all subdirectories of the /home/ricardo/testesfpc directory.

This is what I'm trying to discover.

Cheers
 
Old 12-19-2006, 06:17 PM   #4
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 23
Posts: 72

Rep: Reputation: 19
Here is the command to tar a whole directory:

tar --gzip --create --verbose --file=/home/ricardo/tmp/xxx.tar.gz /home/ricardo/testesfpc

This will tar the whole /home/ricardo/testesfpc directory and all its sub-directories. Since the two files you specified are inside this directory they will also get backed up.

The manual for the tar command and all the other Linux commands should be on your computer already. At the command prompt you can type:

man tar
or
info tar

If you are running KDE you can get access to these commands by typing directly into the Location: area:

man:tar
or
info:tar

I don't run Gnome so I don't know whether this works in Gnome or not. Hope this helps.

Dan

Last edited by dannybpng; 12-19-2006 at 06:30 PM.
 
Old 12-19-2006, 06:21 PM   #5
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 23
Posts: 72

Rep: Reputation: 19
I accidentally double posted and now don't know how to delete a message.

Last edited by dannybpng; 12-19-2006 at 06:27 PM.
 
Old 12-20-2006, 08:22 AM   #6
nightrider
Member
 
Registered: Apr 2005
Location: Sao Paulo - Brazil
Distribution: Open Suse 12.1 64
Posts: 166

Original Poster
Rep: Reputation: 15
Lets see what of conclusion we can get

==================================================================
[ricardo@localhost doc]$ ls -al
total 52
drwxrwxr-x 4 ricardo ricardo 4096 Dez 20 10:36 .
drwx------ 34 ricardo ricardo 4096 Dez 20 10:33 ..
drwxrwxr-x 2 ricardo ricardo 4096 Ago 4 18:39 DocumentaçãoFreePascalLazarus
-rw-rw-r-- 1 ricardo ricardo 17793 Ago 30 09:28 fast_guide_to_linux.odt
drwxrwxr-x 2 ricardo ricardo 4096 Dez 18 15:14 Manual_do_Tarball
-rw-rw-r-- 1 ricardo ricardo 9238 Nov 30 15:42 tar_help.txt
[ricardo@localhost doc]$ tar --gzip --create --verbose --file /home/ricardo/tmp/xxx.tar.gz tar_help.txt
tar_help.txt
[ricardo@localhost doc]$ tar -ztf /home/ricardo/tmp/xxx.tar.gz
tar_help.txt
[ricardo@localhost doc]$
==================================================================

As you can see above, no recursion occurs...

In opposite of your previous afirmation...


Cheers
 
Old 12-20-2006, 12:00 PM   #7
johndoe0028
Member
 
Registered: Jun 2005
Location: CA, USA
Distribution: Gentoo
Posts: 165

Rep: Reputation: 30
Quote:
Originally Posted by nightrider
Lets see what of conclusion we can get

==================================================================
[ricardo@localhost doc]$ ls -al
total 52
drwxrwxr-x 4 ricardo ricardo 4096 Dez 20 10:36 .
drwx------ 34 ricardo ricardo 4096 Dez 20 10:33 ..
drwxrwxr-x 2 ricardo ricardo 4096 Ago 4 18:39 DocumentaçãoFreePascalLazarus
-rw-rw-r-- 1 ricardo ricardo 17793 Ago 30 09:28 fast_guide_to_linux.odt
drwxrwxr-x 2 ricardo ricardo 4096 Dez 18 15:14 Manual_do_Tarball
-rw-rw-r-- 1 ricardo ricardo 9238 Nov 30 15:42 tar_help.txt
[ricardo@localhost doc]$ tar --gzip --create --verbose --file /home/ricardo/tmp/xxx.tar.gz tar_help.txt
tar_help.txt
[ricardo@localhost doc]$ tar -ztf /home/ricardo/tmp/xxx.tar.gz
tar_help.txt
[ricardo@localhost doc]$
==================================================================

As you can see above, no recursion occurs...

In opposite of your previous afirmation...


Cheers
There is no `d' in the permission listing of `tar_help.txt'. It is not a directory.

To tar(gzip) a drectory...
tar -czvf FILE.tar.gz DIR/
Use "j" instead "z" to Bzip2.
 
Old 12-20-2006, 12:24 PM   #8
nightrider
Member
 
Registered: Apr 2005
Location: Sao Paulo - Brazil
Distribution: Open Suse 12.1 64
Posts: 166

Original Poster
Rep: Reputation: 15
I want to tar the file tar_help.txt from the /home/ricardo/doc and all directories that exist under /home/ricardo/doc. I repeat: one file and all the directories under /home/ricardo/doc.

What is the advantage of use Bzip2, please.

Cheers
 
Old 12-20-2006, 12:32 PM   #9
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 545

Rep: Reputation: 33
I suggest trying the tar without the gzip option. You can always gzip it after you tar it.

I prefer gzip over bzip. No advantage I know of to bzip, just another compression pgm.
 
Old 12-20-2006, 03:40 PM   #10
johndoe0028
Member
 
Registered: Jun 2005
Location: CA, USA
Distribution: Gentoo
Posts: 165

Rep: Reputation: 30
Honestly, I use Bzip2 just because "j" is easier for me to hit than "z". >_>

What I would do(Maybe not the best, but oh well) is make a new directoy in your HOME, and copy all the stuff you want tarred into it. Then, tar that folder.
When it comes time to untar it,
tar -xvzf FILE.tar.gz -C /path/to/target/dir

Replace "z" with "j" if you tarred it with "j". "-C" says "I want all files and folders in the tar file to be unzipped to /path/to/target/dir"
 
Old 12-20-2006, 09:47 PM   #11
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 23
Posts: 72

Rep: Reputation: 19
==================================================================
[ricardo@localhost doc]$ ls -al
total 52
drwxrwxr-x 4 ricardo ricardo 4096 Dez 20 10:36 .
drwx------ 34 ricardo ricardo 4096 Dez 20 10:33 ..
drwxrwxr-x 2 ricardo ricardo 4096 Ago 4 18:39 DocumentaçãoFreePascalLazarus
-rw-rw-r-- 1 ricardo ricardo 17793 Ago 30 09:28 fast_guide_to_linux.odt
drwxrwxr-x 2 ricardo ricardo 4096 Dez 18 15:14 Manual_do_Tarball
-rw-rw-r-- 1 ricardo ricardo 9238 Nov 30 15:42 tar_help.txt
[ricardo@localhost doc]$ tar --gzip --create --verbose --file /home/ricardo/tmp/xxx.tar.gz tar_help.txt
tar_help.txt
[ricardo@localhost doc]$ tar -ztf /home/ricardo/tmp/xxx.tar.gz
tar_help.txt
[ricardo@localhost doc]$
==================================================================

In each of your tar commands you are only giving tar a file name(tar_help.txt) not a directory (/home/ricardo/doc). Tar copies every file or directory you specify on the command line. If you give tar a directory name it will tar that directory and everything inside it which in your case includes tar_help.txt:

tar --gzip --create --verbose --file /home/ricardo/tmp/xxx.tar.gz /home/ricardo/doc

This command will tar the directory /home/ricardo/doc and all the files in it which includes tar_help.txt.

Dan
 
Old 12-20-2006, 10:34 PM   #12
zetabill
Member
 
Registered: Oct 2005
Location: Rhode Island, USA
Distribution: Slackware, Xubuntu
Posts: 348

Rep: Reputation: 31
Bzip2 is a different algorithm and is better for large tar files because it compresses things smaller than gzip can. If you ever check out the kernel sources at www.kernel.org, you'll see that the sources come as gz or bz2 tar files. It's the exact same tree but the bz2 files are like 10MB smaller.
 
Old 12-21-2006, 06:23 AM   #13
nightrider
Member
 
Registered: Apr 2005
Location: Sao Paulo - Brazil
Distribution: Open Suse 12.1 64
Posts: 166

Original Poster
Rep: Reputation: 15
After a lot of messages, may I conclude that I can't tar one or two files in a directory and all the directories below?

Is this true?
 
Old 12-21-2006, 11:37 AM   #14
zetabill
Member
 
Registered: Oct 2005
Location: Rhode Island, USA
Distribution: Slackware, Xubuntu
Posts: 348

Rep: Reputation: 31
Messages from us or errors from tar?
Code:
tar czvf docs.tar.gz /home/user/docs/
That is going to put the whole directory structure starting at /home/user/docs into a tar file. That means that everything in docs, all the folders in docs, and all the files in those folders are all included. JohnDoe and others have already posted to this effect.

I guess you can just start out by going to /home/user and just tar czvf docs.tar.gz docs/ it does the same thing.

I think you may be looking too much into this one. If you aren't getting errors than it should be working fine. I'm getting confused.
 
Old 12-21-2006, 05:43 PM   #15
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 23
Posts: 72

Rep: Reputation: 19
One last try using the example directory listing you gave.
==================================================================
[ricardo@localhost doc]$ ls -al
total 52
drwxrwxr-x 4 ricardo ricardo 4096 Dez 20 10:36 .
drwx------ 34 ricardo ricardo 4096 Dez 20 10:33 ..
drwxrwxr-x 2 ricardo ricardo 4096 Ago 4 18:39 DocumentaçãoFreePascalLazarus
-rw-rw-r-- 1 ricardo ricardo 17793 Ago 30 09:28 fast_guide_to_linux.odt
drwxrwxr-x 2 ricardo ricardo 4096 Dez 18 15:14 Manual_do_Tarball
-rw-rw-r-- 1 ricardo ricardo 9238 Nov 30 15:42 tar_help.txt
[ricardo@localhost doc]$ tar --gzip --create --verbose --file /home/ricardo/tmp/xxx.tar.gz tar_help.txt
tar_help.txt
[ricardo@localhost doc]$ tar -ztf /home/ricardo/tmp/xxx.tar.gz
tar_help.txt
[ricardo@localhost doc]$
==================================================================

If you want to tar one file and a directory and all its contents here is what you would type:

cd /home/ricardo/doc
tar --gzip --create --verbose --file /home/ricardo/tmp/xxx.tar.gz /home/ricardo/doc/DocumentaçãoFreePascalLazarus tar_help.txt

(The tar command including the directory and file name is all on one line even though you may see is as two lines in this message)
This command will tar the directory /home/ricardo/doc/DocumentaçãoFreePascalLazarus and all the files in it and also tar the one file tar_help.txt. I you specified other files or directory names on the tar command line it will put all the specified files and directories into the tar file.

Dan
 
  


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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 03:48 AM
Second user account - curious behaviour ? bigjohn Ubuntu 8 06-27-2006 06:02 AM
Curious search behaviour since changes? bigjohn LQ Suggestions & Feedback 6 12-05-2005 11:07 AM
curious: tar -xzvf ... nadroj Linux - Newbie 9 03-28-2005 09:52 PM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 07:30 AM

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

All times are GMT -5. The time now is 05:17 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration