Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: an update command



On Wed, 19 May 2010 09:31:06 +0000 (UTC)
zzapper <david@xxxxxxxxxx> 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@xxxxxxx>            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



Messages sorted by: Reverse Date, Date, Thread, Author