zsh-users
 help / color / mirror / code / Atom feed
* Truncate strings in array
@ 2016-05-22  7:20 Sebastian Gniazdowski
  2016-05-22 10:22 ` Roman Neuhauser
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-05-22  7:20 UTC (permalink / raw)
  To: Zsh Users

Hello,
having array of strings, is it possible to nicely truncate the strings
to given length? Could iterate the array and do truncation, but maybe
there's a one liner?

Best regards,
Sebastian Gniazdowski


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

* Re: Truncate strings in array
  2016-05-22  7:20 Truncate strings in array Sebastian Gniazdowski
@ 2016-05-22 10:22 ` Roman Neuhauser
  2016-05-22 11:14   ` Sebastian Gniazdowski
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Neuhauser @ 2016-05-22 10:22 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh Users

# sgniazdowski@gmail.com / 2016-05-22 09:20:10 +0200:
> having array of strings, is it possible to nicely truncate the strings
> to given length? Could iterate the array and do truncation, but maybe
> there's a one liner?

print -l ${strings/(#m)*/$MATCH[1,30]}

-- 
roman


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

* Re: Truncate strings in array
  2016-05-22 10:22 ` Roman Neuhauser
@ 2016-05-22 11:14   ` Sebastian Gniazdowski
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-05-22 11:14 UTC (permalink / raw)
  To: Roman Neuhauser; +Cc: Zsh Users

On 22 May 2016 at 12:22, Roman Neuhauser <neuhauser@sigpipe.cz> wrote:
> # sgniazdowski@gmail.com / 2016-05-22 09:20:10 +0200:
>> having array of strings, is it possible to nicely truncate the strings
>> to given length? Could iterate the array and do truncation, but maybe
>> there's a one liner?
>
> print -l ${strings/(#m)*/$MATCH[1,30]}

Works, thanks

Best regards,
Sebastian Gniazdowski


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

end of thread, other threads:[~2016-05-22 11:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-22  7:20 Truncate strings in array Sebastian Gniazdowski
2016-05-22 10:22 ` Roman Neuhauser
2016-05-22 11:14   ` 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).