zsh-users
 help / color / mirror / code / Atom feed
* copying a directory to same level
@ 2010-08-21 15:12 zzapper
  2010-08-21 15:33 ` Mikael Magnusson
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: zzapper @ 2010-08-21 15:12 UTC (permalink / raw)
  To: zsh-users

Hi
(Hope this is not too dumb)

I want to duplicate directory vim73 to vim

>cp -r vim73 vim/

if directory vim does not exist then it does what I want.
However if vim/ already exists then vim73/ will be created as a sub-directory 
in vim/ eg vim/vim73

Can you explain this behaviour and how can I force it duplicate to same level 
regardless of whether directory exists



-- 
zzapper
http://zzapper.co.uk/ Technical Tips


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: copying a directory to same level
  2010-08-21 15:12 copying a directory to same level zzapper
@ 2010-08-21 15:33 ` Mikael Magnusson
  2010-08-21 15:36 ` Andrey Borzenkov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Mikael Magnusson @ 2010-08-21 15:33 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

On 21 August 2010 17:12, zzapper <david@tvis.co.uk> wrote:
> Hi
> (Hope this is not too dumb)
>
> I want to duplicate directory vim73 to vim
>
>>cp -r vim73 vim/
>
> if directory vim does not exist then it does what I want.
> However if vim/ already exists then vim73/ will be created as a sub-directory
> in vim/ eg vim/vim73
>
> Can you explain this behaviour and how can I force it duplicate to same level
> regardless of whether directory exists

mkdir vim
cp -r vim73/* vim/

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: copying a directory to same level
  2010-08-21 15:12 copying a directory to same level zzapper
  2010-08-21 15:33 ` Mikael Magnusson
@ 2010-08-21 15:36 ` Andrey Borzenkov
  2010-08-21 16:12 ` Bart Schaefer
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Andrey Borzenkov @ 2010-08-21 15:36 UTC (permalink / raw)
  To: zsh-users; +Cc: zzapper

[-- Attachment #1: Type: Text/Plain, Size: 585 bytes --]

On Saturday 21 of August 2010 19:12:37 zzapper wrote:
> Hi
> (Hope this is not too dumb)
> 
> I want to duplicate directory vim73 to vim
> 
> >cp -r vim73 vim/
> 
> if directory vim does not exist then it does what I want.
> However if vim/ already exists then vim73/ will be created as a
> sub-directory in vim/ eg vim/vim73
> 
> Can you explain this behaviour

This is how cp command works and is unrelated to shell.

> and how can I force it duplicate to
> same level regardless of whether directory exists

GNU cp has -T option that does exactly what you want.

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: copying a directory to same level
  2010-08-21 15:12 copying a directory to same level zzapper
  2010-08-21 15:33 ` Mikael Magnusson
  2010-08-21 15:36 ` Andrey Borzenkov
@ 2010-08-21 16:12 ` Bart Schaefer
  2010-08-22 12:51 ` zzapper
  2010-08-22 18:32 ` Benjamin R. Haskell
  4 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2010-08-21 16:12 UTC (permalink / raw)
  To: zsh-users

On Aug 21,  3:12pm, zzapper wrote:
}
} (Hope this is not too dumb)

Not dumb, but it's a "cp" thing rather than a shell thing.

} >cp -r vim73 vim/
} 
} if directory vim does not exist then it does what I want.
} However if vim/ already exists then vim73/ will be created as a sub-directory 
} in vim/ eg vim/vim73

Referring to the "cp" documentation (GNU "info" in this case):

   If the last argument names an existing directory, `cp' copies each
   SOURCE file into that directory (retaining the same name).

Consequently what you want is:

    cp -r vim73/. vim

which will change "." to "vim" if "vim" doesn't already exist, and copy
the contents of vim73/. into vim/. if "vim" already does exist.

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: copying a directory to same level
  2010-08-21 15:12 copying a directory to same level zzapper
                   ` (2 preceding siblings ...)
  2010-08-21 16:12 ` Bart Schaefer
@ 2010-08-22 12:51 ` zzapper
  2010-08-22 18:32 ` Benjamin R. Haskell
  4 siblings, 0 replies; 7+ messages in thread
From: zzapper @ 2010-08-22 12:51 UTC (permalink / raw)
  To: zsh-users

zzapper wrote in news:Xns9DDBA4E47D3B3zzappergmailcom@80.91.229.10:

> Hi
> (Hope this is not too dumb)
> 
> I want to duplicate directory vim73 to vim
> 
>>cp -r vim73 vim/
> 
> 
> 
> 
Thanks for all responses.
In fact i had used (and forgotten) the following solution in the past  

cp -r vim73/. vim

-- 
zzapper
http://zzapper.co.uk/ Technical Tips


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: copying a directory to same level
  2010-08-21 15:12 copying a directory to same level zzapper
                   ` (3 preceding siblings ...)
  2010-08-22 12:51 ` zzapper
@ 2010-08-22 18:32 ` Benjamin R. Haskell
  2010-08-22 18:36   ` Benjamin R. Haskell
  4 siblings, 1 reply; 7+ messages in thread
From: Benjamin R. Haskell @ 2010-08-22 18:32 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

On Sat, 21 Aug 2010, zzapper wrote:

> Hi
> (Hope this is not too dumb)
> 
> I want to duplicate directory vim73 to vim
> 
> >cp -r vim73 vim/
> 
> if directory vim does not exist then it does what I want.  However if 
> vim/ already exists then vim73/ will be created as a sub-directory in 
> vim/ eg vim/vim73
> 
> Can you explain this behaviour and how can I force it duplicate to 
> same level regardless of whether directory exists

Personally, I use rsync for anything like this.  For your particular use 
case, you'd want:

rsync -r vim73/ vim/

Note the trailing slash on vim73/.  If you omit it, you'll get a 
vim/vim73/ subdirectory.  In both cases, though, the final outcome 
doesn't depend on whether vim/ already exists.


Although, it also sounds suspiciously as though you're trying to go 
against recommendations and muck about in the $VIM/ or $VIMRUNTIME/ 
directories directly (rather than making modifications in your own home 
directory).


Or, maybe you're looking for symbolic links.  I've seen on many systems:

/usr/share/vim/current -> vim72

Modified for what I assume you might want in your example, that can be 
created by:

ln -s vim73 /usr/share/vim/vim

-- 
Best,
Ben


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: copying a directory to same level
  2010-08-22 18:32 ` Benjamin R. Haskell
@ 2010-08-22 18:36   ` Benjamin R. Haskell
  0 siblings, 0 replies; 7+ messages in thread
From: Benjamin R. Haskell @ 2010-08-22 18:36 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

On Sun, 22 Aug 2010, Benjamin R. Haskell wrote:

> On Sat, 21 Aug 2010, zzapper wrote:
> 
> > Hi
> > (Hope this is not too dumb)
> > 
> > I want to duplicate directory vim73 to vim
> > 
> > >cp -r vim73 vim/
> > 
> > if directory vim does not exist then it does what I want.  However if 
> > vim/ already exists then vim73/ will be created as a sub-directory in 
> > vim/ eg vim/vim73
> > 
> > Can you explain this behaviour and how can I force it duplicate to 
> > same level regardless of whether directory exists
> 
> Personally, I use rsync for anything like this.  For your particular use 
> case, you'd want:
> 
> rsync -r vim73/ vim/
> 
> Note the trailing slash on vim73/.  If you omit it, you'll get a 
> vim/vim73/ subdirectory.  In both cases, though, the final outcome 
> doesn't depend on whether vim/ already exists.
> 
> 
> Although, it also sounds suspiciously as though you're trying to go 
> against recommendations and muck about in the $VIM/ or $VIMRUNTIME/ 
> directories directly (rather than making modifications in your own home 
> directory).
> 
> 
> Or, maybe you're looking for symbolic links.  I've seen on many systems:
> 
> /usr/share/vim/current -> vim72
> 
> Modified for what I assume you might want in your example, that can be 
> created by:
> 
> ln -s vim73 /usr/share/vim/vim
> 
> 

Oops, sorry.  I was in Vim mailing list mode.  I didn't realize this was 
on Zsh Users.  (Nor had I seen the other responses.)  The Vim-related 
advice still stands, though.

-- 
Best,
Ben


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-08-22 18:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-21 15:12 copying a directory to same level zzapper
2010-08-21 15:33 ` Mikael Magnusson
2010-08-21 15:36 ` Andrey Borzenkov
2010-08-21 16:12 ` Bart Schaefer
2010-08-22 12:51 ` zzapper
2010-08-22 18:32 ` Benjamin R. Haskell
2010-08-22 18:36   ` Benjamin R. Haskell

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).