LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 08-15-2004, 09:00 PM   #1
Earl Parker II
Member
 
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127

Rep: Reputation: 17
tar: '--no-recursion' option doesn't prevent recursion


Referring to the command below:
Code:
tar -cvlpf backup.tar --no-recursion /directory
The --no-recursion option doesn't seem to be preventing recursion into subdirectories of 'directory'- does anyone know why? Thanks for any help!
 
Old 08-15-2004, 09:41 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,000
Blog Entries: 11

Rep: Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893
Please post ...

tar --version

I'm just curious, because the tar 1.14 from Slack and
1.13.25 from Deb stable doesn't even have that option
according to their man-pages ...

[edit]
Hehe ... info, however, does ...
With the output of tar --help I'd assume that --no-recursion
only works in conjunction with -h
[edit]


Cheers,
Tink

Last edited by Tinkster; 08-15-2004 at 09:54 PM.
 
Old 08-15-2004, 11:14 PM   #3
Earl Parker II
Member
 
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127

Original Poster
Rep: Reputation: 17
Thanks for replying.

The tar version is 1.14. According to the man page '-h' means 'don't dump symlinks; dump the files they point to'. Out of curiosity (and I'm asking this honestly), why do you think that '--no-recursion' will only work with the '-h' option?

Note: I just added '-h' and it didn't seem to make any difference.
 
Old 08-16-2004, 01:00 AM   #4
Mephisto
Member
 
Registered: Oct 2002
Location: Washington D.C, USA
Distribution: Slack 12, Etch, Gutsy
Posts: 453

Rep: Reputation: 30
Why would you want to make a tar file out of a single directory entry and no files?

You could do a
Code:
    tar -cvvf backup.tar --no-recursion myDirectory/*
to backup just the files in the directory. Note it will create the directories inside MyDirectory, they should be empty though.
 
Old 08-16-2004, 01:09 AM   #5
Earl Parker II
Member
 
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127

Original Poster
Rep: Reputation: 17
I apologize for not explaining the situation better. I'm tarring three directories, all containing a number of files and subdirectories containing files. I just used '/directory' in the original post as a placeholder. In two of the directories I'd like to avoid recursion, while in the third one I need recursion.

I just tried
Code:
tar -cvvf backup.tar --no-recursion myDirectory/*
(substituting my directroy path of course) and tar still descends into and copies files in subdirectories.

Perhaps I don't understand the concept of recursion?

Last edited by Earl Parker II; 08-16-2004 at 01:14 AM.
 
Old 08-16-2004, 01:18 AM   #6
Mephisto
Member
 
Registered: Oct 2002
Location: Washington D.C, USA
Distribution: Slack 12, Etch, Gutsy
Posts: 453

Rep: Reputation: 30
No you seem to be understanding it correctly, though if your statements are accurate it is a mystery to me. I tested with -cvvf and -cvlpf multiple times (though always a single directory) and it worked, copying just the files and the immediate subdirectories. So I have no idea.

EDIT: I am using tar 1.14 as well (from Slack 10 if it makes a difference)

Last edited by Mephisto; 08-16-2004 at 01:20 AM.
 
Old 08-16-2004, 01:36 AM   #7
Earl Parker II
Member
 
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127

Original Poster
Rep: Reputation: 17
OK, I've narrowed down the problem a bit. When I enter
Code:
tar -cvvf backup.tar --no-recursion /directory/*
it works just fine. If I enter
Code:
tar -cvvf backup.tar --no-recursion /directory/* /directory/subdirectory/*
it also gives the desired result. However, if I enter
Code:
tar -cvvf backup.tar --no-recursion /directory/* /directory/subdirectory/* --recursion /directory/subdirectory/*
then --no-recursion appears to be ignored and --recursion is applied to all subdirectories. According to the tar info page this should work but for some reason it doesn't. Any thoughts?

Last edited by Earl Parker II; 08-16-2004 at 01:38 AM.
 
Old 08-16-2004, 03:59 AM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,000
Blog Entries: 11

Rep: Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893
Quote:
Originally posted by Earl Parker II
Thanks for replying.

The tar version is 1.14. According to the man page '-h' means 'don't dump symlinks; dump the files they point to'. Out of curiosity (and I'm asking this honestly), why do you think that '--no-recursion' will only work with the '-h' option?

Note: I just added '-h' and it didn't seem to make any difference.
Because of the layout it gives in tar --help

Not really a good reason, I admit, but to me
it looks like some sort of "grouping" ... other-
wise I wouldn't have an explanation for the
'chaotic' way the help output comes across.


Cheers,
Tink
 
Old 08-16-2004, 11:12 AM   #9
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,680

Rep: Reputation: Disabled
tar the recursive directory first (1. position in the comand) and thereafter the --no-recursive ones?
 
Old 08-16-2004, 11:40 AM   #10
Earl Parker II
Member
 
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127

Original Poster
Rep: Reputation: 17
Funny you should mention that becuase I've been experimenting with that in the last few minutes. What I've found is this: if you specify '--no-recursion' first, then '--recursion', everything defaults to '--recursion'. The reverse is also true. Whichever comes last in the tar command- '--no-recursion' or '--recursion'- becomes the default. I'm getting the feeling that I'm either leaving something out or the command simply doesn't work the way the info page states.
 
Old 08-16-2004, 12:56 PM   #11
cspangen
LQ Newbie
 
Registered: Dec 2002
Location: Jenison, MI
Distribution: S.u.S.E.
Posts: 3

Rep: Reputation: 0
Why not append?

Instead of creating one command to do all the directories why not
tar the recursive directory or non-recursive directories first then
append the other directorie(s). Do a a check on the tar command and if it succends then tar the remander.


Carl
 
Old 08-16-2004, 01:10 PM   #12
Earl Parker II
Member
 
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127

Original Poster
Rep: Reputation: 17
Not trying to anticipate you but that was just about my next move. '--no-recursion' and '--recursion' just don't seem to play well together.

If I understand correctly the idea is to create the first tarball then create the secondar tarball and append it to the first- am I understanding correctly? If not, let me know. I'll give it a try later today.

Last edited by Earl Parker II; 08-16-2004 at 01:12 PM.
 
Old 08-17-2004, 03:49 AM   #13
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,680

Rep: Reputation: Disabled
Still, you might want to notify the tar maintainers if it is not behaving according to the info.

BTW you can still do it with one command when you use a control-file to manage the input for tar...
 
  


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
chmod recursion -- files only Risc91 AIX 12 09-18-2012 09:58 AM
Recursion in C hubabuba Programming 12 10-03-2005 08:46 AM
Perl, recursion ivanatora Programming 11 03-14-2005 02:49 PM
Writing bash script with recursion.. ray5_83 Programming 4 08-04-2004 06:44 PM
help with recursion function debdas Programming 4 05-14-2003 04:03 AM


All times are GMT -5. The time now is 12:46 AM.

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