help-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-tar] Using --directory and --no-recursion


From: Reuti
Subject: Re: [Help-tar] Using --directory and --no-recursion
Date: Sun, 10 Feb 2019 16:01:16 +0100

Hi,

Am 10.02.2019 um 14:13 schrieb Brian Wengel:

> Hello tar community
>  
> I have some challenges using the –directory together with --no-recursion 
> option.
> I’m using version 1.30 on Debian Stretch
>  
> The --directory option seem to be ignored, e.g.:
> tar --directory="/tmp/fld 1/" --create --file="/tmp/fld 1/files.tar" 
> --exclude="files.tar" --no-recursion .
> Archive is created in “/tmp/fld 1/” but it’s rather empty (have an empty ./ 
> entry)
> Tried to use different kind of wildcards but haven’t been successful.
> I’m trying to create an archive without full-path information and no 
> recursion.

It seems to stay in "." and already descending into it is not performed. Even 
if it would do this one step, it would include the directories in this 
directory. But as he shouldn't descend into them, they will be empty in the 
archive. E.g. something like:

 File1
 File2
 File3
 Subdir

and Subdir is a directory. I would assume that you want the plain files in the 
particular directory only. I don't know whether it's feasible for your case, 
but a `find` could help:

$ find "/tmp/fld 1/" -maxdepth 1 -type f \! -name "files.tar" -execdir tar cf 
"/tmp/fld 1/files.tar" {} +

Files will have the names:

./File1
./File2
./File3

though, but it shouldn't hurt.

-- Reuti


> And one could also argue that using --file="files.tar" would save the archive 
> in the folder specified in the --directory option, but that’s not the case, 
> it’s located in “current” folder, in my case home.
>  
> If I try:
> tar --directory="/tmp/fld 1/" --create --file="/tmp/fld 1/files.tar" 
> --exclude="files.tar" --no-recursion "/tmp/fld 1/”*
> Archive is created in “/tmp/fld 1/” with expected content but it has 
> full-path information.
>  
> After reading the manual it was my expectation that the first example should 
> work:
> -C, --directory=DIR
> Change to DIR before performing any operations.  This option is 
> order-sensitive, i.e. it affects all options that follow.
> This is for ver. 1.29
> 
> Best regards
> Brian Wengel
> Denmark
>  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]