zsh-users
 help / color / mirror / code / Atom feed
* Rotate words in string
@ 2016-05-10  5:39 Sebastian Gniazdowski
  2016-05-10 10:26 ` Roman Neuhauser
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-05-10  5:39 UTC (permalink / raw)
  To: Zsh Users

Hello,
having space separated string of words, how to nicely rotate the words
in it? So:
word1 word2 word3

becomes:
word3 word1 word2

and so on?

Best regards,
Sebastian Gniazdowski


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

* Re: Rotate words in string
  2016-05-10  5:39 Rotate words in string Sebastian Gniazdowski
@ 2016-05-10 10:26 ` Roman Neuhauser
  2016-05-10 12:36   ` Sebastian Gniazdowski
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Neuhauser @ 2016-05-10 10:26 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh Users

# sgniazdowski@gmail.com / 2016-05-10 07:39:22 +0200:
> having space separated string of words, how to nicely rotate the words
> in it? So:
> word1 word2 word3
> 
> becomes:
> word3 word1 word2
> 
> and so on?

turn it into an array, then:

words=($words[-1] $words[1,-2])

-- 
roman


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

* Re: Rotate words in string
  2016-05-10 10:26 ` Roman Neuhauser
@ 2016-05-10 12:36   ` Sebastian Gniazdowski
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-05-10 12:36 UTC (permalink / raw)
  To: Roman Neuhauser; +Cc: Zsh Users

On 10 May 2016 at 12:26, Roman Neuhauser <neuhauser@sigpipe.cz> wrote:
> turn it into an array, then:
>
> words=($words[-1] $words[1,-2])

Thanks

Sebastian Gniazdowski


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

end of thread, other threads:[~2016-05-10 12:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-10  5:39 Rotate words in string Sebastian Gniazdowski
2016-05-10 10:26 ` Roman Neuhauser
2016-05-10 12:36   ` Sebastian Gniazdowski

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