coreutils
[Top][All Lists]
Advanced

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

Re: Advanced syntax for cp --parents


From: Reuti
Subject: Re: Advanced syntax for cp --parents
Date: Mon, 23 Jan 2017 17:18:12 +0100

> Am 23.01.2017 um 16:48 schrieb Fergus <address@hidden>:
> 
> Starting at b3/ I need to copy everything under /b1/b2/b3/b4/b5 to
> /{pathname} (i.e. to create /{pathname}/b3/b4/b5 with all descendants).
> To achieve this I move from present location to /b1/b2 and then use cp with
> the switch --parents:
> $ cd    /b1/b2
> $ cp    -vr    --parents    b3/b4/b5    /{pathname}

I think the --parents isn't necessary with -r already given (if this is why you 
are using it).

Hence:

$ cp -vr /b1/b2/b3 /{pathname}

should create b3 in /{pathname}


> Is there a way I can achieve this without an explicit change directory?

Or put it in a subshell, so that you don't have to `cd` back:

(cd /b1/b2; cp -vr b3 /{pathname})

-- Reuti


> For example: a similar requirement to tar the same subdirectory as above
> with all descendants can be achieved through
> $ tar -cf archive.tar -C /b1/b2  b3/b4/b5
> where the switch -C  DIR indicates a virtual change directory to DIR before
> performing any operations.
> i.e. I am seeking similar versatility for cp, to that provided by -C DIR for
> tar.
> Any ideas?
> Thank you!
> Fergus
> 
> 

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail


reply via email to

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