zsh-users
 help / color / mirror / code / Atom feed
* an update command
@ 2010-05-19  9:31 zzapper
  2010-05-19 10:02 ` Peter Stephenson
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: zzapper @ 2010-05-19  9:31 UTC (permalink / raw)
  To: zsh-users

Hi
when copying files from a test server to a live server eg

>cp $T/config.php $L

I only want to do the copy if the file ALREADY exists in the destination 
directory 

I guess I can hack a script up to do this but how would you do this? 
-- 
zzapper
http://zzapper.co.uk/ Technical Tips


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

* Re: an update command
  2010-05-19  9:31 an update command zzapper
@ 2010-05-19 10:02 ` Peter Stephenson
  2010-05-19 10:26 ` François Gannaz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2010-05-19 10:02 UTC (permalink / raw)
  To: zsh-users

On Wed, 19 May 2010 09:31:06 +0000 (UTC)
zzapper <david@tvis.co.uk> wrote:
> when copying files from a test server to a live server eg
> 
> >cp $T/config.php $L
> 
> I only want to do the copy if the file ALREADY exists in the
> destination directory 
> 
> I guess I can hack a script up to do this but how would you do this? 

if $L is a directory,

  [[ -e $L/config.php ]] && cp $T/config.php $L

which is easy to turn into a function in various ways.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


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

* Re: an update command
  2010-05-19  9:31 an update command zzapper
  2010-05-19 10:02 ` Peter Stephenson
@ 2010-05-19 10:26 ` François Gannaz
  2010-05-19 10:37 ` Joke de Buhr
  2010-05-19 13:01 ` zzapper
  3 siblings, 0 replies; 5+ messages in thread
From: François Gannaz @ 2010-05-19 10:26 UTC (permalink / raw)
  To: zsh-users

Le 2010-05-19, zzapper <david@tvis.co.uk> a écrit :
> Hi
> when copying files from a test server to a live server eg
> 
> >cp $T/config.php $L
> 
> I only want to do the copy if the file ALREADY exists in the destination 
> directory 
> 
> I guess I can hack a script up to do this but how would you do this? 

That's not related to zsh, but I would use `rsync` with `--existing`.
Rsync is especially useful when files are updated.

Regards
--
François


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

* Re: an update command
  2010-05-19  9:31 an update command zzapper
  2010-05-19 10:02 ` Peter Stephenson
  2010-05-19 10:26 ` François Gannaz
@ 2010-05-19 10:37 ` Joke de Buhr
  2010-05-19 13:01 ` zzapper
  3 siblings, 0 replies; 5+ messages in thread
From: Joke de Buhr @ 2010-05-19 10:37 UTC (permalink / raw)
  To: zsh-users

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

You should probably have a look at rsync.

use this command:

   cd $L          // go into the remote directory you want to sync
   print -l **(.) | rsync -av --dry-run --files-from=- $T $L

If rsync lists only the lists you want to copy remove the --dry-run option. 
Create a backup tar archive if you are unsure.



On Wednesday 19 May 2010 11:31:06 zzapper wrote:
> Hi
> when copying files from a test server to a live server eg
> 
> >cp $T/config.php $L
> 
> I only want to do the copy if the file ALREADY exists in the destination
> directory
> 
> I guess I can hack a script up to do this but how would you do this?

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

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

* Re: an update command
  2010-05-19  9:31 an update command zzapper
                   ` (2 preceding siblings ...)
  2010-05-19 10:37 ` Joke de Buhr
@ 2010-05-19 13:01 ` zzapper
  3 siblings, 0 replies; 5+ messages in thread
From: zzapper @ 2010-05-19 13:01 UTC (permalink / raw)
  To: zsh-users

zzapper wrote in news:Xns9D7D6AFA2B217zzappergmailcom@80.91.229.10:

> Hi
> when copying files from a test server to a live server eg
> 
>>cp $T/config.php $L
> 
> I only want to do the copy if the file ALREADY exists in the destination 
> directory 

Thanks for responses all good stuff.

Curiously cp has a parameter -update which only copies if src newer than 
dest, unfortunately  (for me) will create a new dest file if none exists



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


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

end of thread, other threads:[~2010-05-19 13:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-19  9:31 an update command zzapper
2010-05-19 10:02 ` Peter Stephenson
2010-05-19 10:26 ` François Gannaz
2010-05-19 10:37 ` Joke de Buhr
2010-05-19 13:01 ` zzapper

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).