zsh-users
 help / color / mirror / code / Atom feed
* copying to a deep parallel directory
@ 2013-11-06 17:21 zzapper
  2013-11-06 17:46 ` Jérémie Roquet
  2013-11-06 17:51 ` Peter Stephenson
  0 siblings, 2 replies; 5+ messages in thread
From: zzapper @ 2013-11-06 17:21 UTC (permalink / raw)
  To: zsh-users

Hi
Say I want to copy a file from

/var/www/html/admin/include/

to

/var/www/live/admin/include/

I can of course


cd html live

and then I can use $OLDPWD or ~+1

but is there anything niftier?

zzapper
https://twitter.com/dailyzshtip


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

* Re: copying to a deep parallel directory
  2013-11-06 17:21 copying to a deep parallel directory zzapper
@ 2013-11-06 17:46 ` Jérémie Roquet
  2013-11-06 17:51 ` Peter Stephenson
  1 sibling, 0 replies; 5+ messages in thread
From: Jérémie Roquet @ 2013-11-06 17:46 UTC (permalink / raw)
  To: zzapper; +Cc: Zsh Users

Hi,

2013/11/6 zzapper <david@rayninfo.co.uk>:
> Say I want to copy a file from
>
> /var/www/html/admin/include/
>
> to
>
> /var/www/live/admin/include/
>
> I can of course
>
> cd html live
>
> and then I can use $OLDPWD or ~+1
>
> but is there anything niftier?

$PWD:s/html/live/ or ${PWD/html/live} ?

-- 
Jérémie


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

* Re: copying to a deep parallel directory
  2013-11-06 17:21 copying to a deep parallel directory zzapper
  2013-11-06 17:46 ` Jérémie Roquet
@ 2013-11-06 17:51 ` Peter Stephenson
  2013-11-06 18:00   ` zzapper
  2013-11-06 20:03   ` Dan Nelson
  1 sibling, 2 replies; 5+ messages in thread
From: Peter Stephenson @ 2013-11-06 17:51 UTC (permalink / raw)
  To: zsh-users

On Wed, 06 Nov 2013 17:21:23 +0000 (UTC)
zzapper <david@rayninfo.co.uk> wrote:
> Say I want to copy a file from
> 
> /var/www/html/admin/include/
> 
> to
> 
> /var/www/live/admin/include/
> 
> I can of course
> 
> 
> cd html live
> 
> and then I can use $OLDPWD or ~+1
> 
> but is there anything niftier?

So we're assuming you're in the former directory...

cp <file> ${PWD/html/live}

This syntax gets a bit messy if you're changing multiple levels
since you need to quote the slashes.

pws


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

* Re: copying to a deep parallel directory
  2013-11-06 17:51 ` Peter Stephenson
@ 2013-11-06 18:00   ` zzapper
  2013-11-06 20:03   ` Dan Nelson
  1 sibling, 0 replies; 5+ messages in thread
From: zzapper @ 2013-11-06 18:00 UTC (permalink / raw)
  To: zsh-users


>> Say I want to copy a file from
>> 
>> /var/www/html/admin/include/
>> 
>> to
>> 
>> /var/www/live/admin/include/
>> 

> cp <file> ${PWD/html/live}
> 
> This syntax gets a bit messy if you're changing multiple levels
> since you need to quote the slashes.
> 
> pws
> 

Thanks that's cute, I will so be using this! 
JWTDO

zzapper


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

* Re: copying to a deep parallel directory
  2013-11-06 17:51 ` Peter Stephenson
  2013-11-06 18:00   ` zzapper
@ 2013-11-06 20:03   ` Dan Nelson
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Nelson @ 2013-11-06 20:03 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

In the last episode (Nov 06), Peter Stephenson said:
> On Wed, 06 Nov 2013 17:21:23 +0000 (UTC)
> zzapper <david@rayninfo.co.uk> wrote:
> > Say I want to copy a file from
> > 
> > /var/www/html/admin/include/
> > 
> > to
> > 
> > /var/www/live/admin/include/
> > 
> > I can of course
> > 
> > cd html live
> > 
> > and then I can use $OLDPWD or ~+1
> > 
> > but is there anything niftier?
> 
> So we're assuming you're in the former directory...
> 
> cp <file> ${PWD/html/live}
> 
> This syntax gets a bit messy if you're changing multiple levels
> since you need to quote the slashes.

I use brace expansion a lot for things like this.

cp /var/www/{html,live}/admin/include/file.html

-- 
	Dan Nelson
	dnelson@allantgroup.com


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

end of thread, other threads:[~2013-11-06 20:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-06 17:21 copying to a deep parallel directory zzapper
2013-11-06 17:46 ` Jérémie Roquet
2013-11-06 17:51 ` Peter Stephenson
2013-11-06 18:00   ` zzapper
2013-11-06 20:03   ` Dan Nelson

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